6 Replies - 990 Views - Last Post: 17 December 2011 - 10:40 PM

#1 Invisibledeath  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 79
  • Joined: 13-March 10

What kind of mindset you should use when programming?

Posted 15 December 2011 - 08:17 AM

I am asking what kind of thinking to use, when solving programming problems. That is how to think about the problem in algorithmic way.

This post has been edited by Invisibledeath: 15 December 2011 - 08:35 AM

Is This A Good Question/Topic? 0
  • +

Replies To: What kind of mindset you should use when programming?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8910
  • View blog
  • Posts: 33,420
  • Joined: 12-June 08

Re: What kind of mindset you should use when programming?

Posted 15 December 2011 - 08:18 AM

Rage!


Would you elaborate what you are asking for?
Was This Post Helpful? 1
  • +
  • -

#3 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2528
  • View blog
  • Posts: 4,630
  • Joined: 24-September 10

Re: What kind of mindset you should use when programming?

Posted 15 December 2011 - 08:32 AM

I think they're asking the mental process one should use to "problem solve".

...

Which is kind of confounding... it's hard for one to explain the art of problem solving. Especially since different people approach problem solving, in their heads, from different ways. Actually problem solving as a whole is the art of approaching a problem from different directions at the same time and deducing which is the most efficient, relative to your other ideas.

...

I guess it could be an interesting thought discussion. But really wouldn't be the most practical of discussions, and OP isn't going to leave better knowing how to problem solve. Practice, or "exercise", IS the way you hone that skill. It's like asking one to explain how to build muscle, and walking away with muscles once hearing about how I lift weights.

PRACTICE!
Was This Post Helpful? 0
  • +
  • -

#4 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7564
  • View blog
  • Posts: 12,681
  • Joined: 19-March 11

Re: What kind of mindset you should use when programming?

Posted 15 December 2011 - 09:13 AM

Quote

PRACTICE!


This. Get a copy of Sedgewick and crank through it, do all of the problems. When you've done that, write an XML parser, a word processor, a rogue-like game, whatever. Just set yourself problems that you don't know how to solve, and solve the hell out of them. Reinvent a lot of wheels until they start coming out round.
Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2889
  • View blog
  • Posts: 10,003
  • Joined: 08-August 08

Re: What kind of mindset you should use when programming?

Posted 15 December 2011 - 10:26 AM

Programming to me is about organizing thoughts. If you can't organize your thoughts (and that's never easy) then your code will be disorganized and unreadable. If it's unreadable then it will be full of bugs at best and fail completely at worst.

When most people start learning to code they write what amounts to a list of instructions. When that list gets long enough they become confused. It's functions, structs and classes that allow programmers to organize lists of instructions into manageable chunks that reduce or eliminate confusion. My advice would be to spend some time thinking about what parts of your code belong in what functions and what functions belong in classes/structs.
Was This Post Helpful? 0
  • +
  • -

#6 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1939
  • View blog
  • Posts: 4,027
  • Joined: 11-December 07

Re: What kind of mindset you should use when programming?

Posted 17 December 2011 - 08:25 AM

For the most tricky of problems, I find that my subconscious is the best tool. Often after a nights sleep or playing sports for a while, I return to the problem and quickly see a solution. Sometimes, taking my mind off it leads to a "eureka" moment when I'm in the shower or on a bus (certainly somewhere away from my computer).

One time, I was working on a commission and had hit a brick wall. I took a short nap and the part of the program I was having difficulties with seemed trivial. In the end, I didn't bill for the time spent asleep but in this case, it was an important part of the problem solving process.

As well as solving problems, this is a useful skill for making life decisions. Often, waking up after a good night of sleep, the best option is a lot clearer. I guess this is where the phrase "sleeping on it" comes from.

That said, none of this is a reason for goofing off. You'd never get any work done!
Was This Post Helpful? 0
  • +
  • -

#7 RodgerB  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 66
  • View blog
  • Posts: 2,284
  • Joined: 21-September 07

Re: What kind of mindset you should use when programming?

Posted 17 December 2011 - 10:40 PM

I am self-taught, so take my post with a grain of salt. What I say and what a lecturer says may be two different things.

Before I complete a task, I ask myself, is there anything that could potentially become a problem down the track with the way I am writing the code. Is this something I should be nutting out on paper / using maths to help me accomplish the task? Is the algorithm I'm creating going to be reused in the future, and would it be better off if I made it into a function? Is my software adhering to an MVC type architectural model? Am I naming my methods and variable names with names that help ensure the code is readable? Am I making appropriate comments about my code, for others who would like to read it to help them follow what is happening?

Am I 100% sure that the behavior of the code I'm writing matches that of the logic I am attempting to implement (for instance, when creating a for loop in VB.NET, you need to subtract 1 from the Count property of a collection in some cases). If I am not, I make a quick test run outputting to console or a test suite values that I may unexpectedly run into.

Do I need to Garbage Collect? If so, have I garbage collected properly?

After developing the algorithm and ensuring the logic is all correct, I then ask myself is there anyway the algorithm can be made more efficient? Could I cut down on some code here and there, whilst still keeping the code readable.

To me, programming should be approached with an inquisitive and exploratory mindset - by applying this type of psychological mindset, you are able to find problems, and hence solve them. But your problem solving skills are enhanced by practicing. The more mistakes you make, the better prepared you will be to solve more complex problems.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1