4

Possible Duplicate:
How can I improve my problem-solving ability?

When starting a programming task, I have trouble breaking it up into steps and figuring out how to go about solving it.

I want to get better at it. Should I to focus on data structures/algorithms? Or should I be studying more design patterns?

What do you think would help in thinking more logically and being able to break things into steps?

Crystal
  • 149
  • 2
  • 1
    Obligatory reference to http://projecteuler.net. Seriously, the questions are a great mix of math and programming. I'm not sure I've ever seen a better set of exercises to help improve logic skills. – Brandon Moretz Oct 01 '11 at 05:26

4 Answers4

7

i have trouble seeing the logic in code sometimes

This is common, don't worry about it. Understanding code that you're not familiar with is much like trying to understand how someone else thinks. Usually getting a walkthrough of that entire portion (not the entire system as it may make your head explode if the entire system is big enough) of the system architecture helps a great deal. Once you understand the overarching solution, the logic in the specific code chunks can start to make quite a bit more sense.

It sounds to me like you need practice at system architecture. The next time you're tackling a problem, forget about the code. First, fully understand the problem that you're dealing with. Of course, if you don't fully understand a given problem, engineering a solution will be difficult at best. Next, take a look to see if there's an implementation for that problem readily available (OS), or if there's a design pattern that can be applied to it (Wikipedia has a decent list). If not, then start desiging a solution (still not even thinking about the code - all of this should be abstract design).

Once your design is done, then start coding.

Of course, studying design patterns and algorithms (and algorithm design/analysis) will most definitely help you in your conquest here, but practice really is just as important (whether you actually implement your designs or not is beside the point).

Doing this enough times will help spur that abstract problem solving thinking that you seem to be having issues with.

And don't ever forget: No matter how good you think you get at this, there will always be someone (or a number of someones) who are quicker/better/brighter than you. Use them to help you get better - don't let their abilities frustrate you.

Demian Brecht
  • 17,555
  • 1
  • 47
  • 81
5

I think its quite simple: code more!

Your problem sounds exactly what i had when i started programming. And the only way to go around it was to just code more, more and more! Only then you can have the real grasp on it.

Just start small, dont go on big projects first.

kaino
  • 69
  • 2
  • 1
    -1: Coding has nothing to do with abstract problem solving. – Demian Brecht Oct 01 '11 at 05:27
  • thats not my point actually. but to understand the flow of the program. thanks for downvote for perfect valid answer... – kaino Oct 01 '11 at 05:29
  • 4
    Simply coding more does *not* help someone with abstract problem solving. While it can help you understand how others may solve specific use cases as well as getting a better grasp your language of choice, it does not help with fundamental engineering concepts, or help with one's ability to break down problems into logical sections. – Demian Brecht Oct 01 '11 at 06:08
  • 1
    No downvote, but I agree with Damian: Just repeating what you're doing over and over will at best make you better at what you can do already (and at worst it will reinforce bad habits). It's not a good way to learn new ways of thinking, though. – nikie Oct 01 '11 at 08:39
  • Can confirm. I've been coding for 6 years but have always found 'something missing'. On a similar quest as OP. Downvote is a bit harsh though. – Anon Dec 25 '16 at 16:04
1

I'm currently taking a course called "Algorithms Analysis". This class is ALL about breaking problems up into steps and solving them (with an emphasis on optimization).

You should study algorithms. After studying an algorithm, close your eyes and try to recreate the entire algorithm on your own. It's important to understand each step at a higher level than just memorization so you can apply it to different examples. With practice, you will get quicker.

Casey Patton
  • 5,211
  • 7
  • 33
  • 41
0

Chances are somebody has already met a similar functionnal problem and explained it on the web. If you don't know where to start, asking on the web is a valid solution.

Better than writing crap code anyway.

What language do you use? algorythms is more about knowing your API.

But you are right, learning design patterns indeed will make you a better programmer, so few people know them in the industry.

xsace
  • 695
  • 4
  • 15
  • I'm confused. How are algorithms "more about knowing your API"? Algorithms "can be considered to be any sequence of operations that can be simulated by a Turing-complete system" (Wikipedia), which doesn't have anything to do with a specific API. They're a series of abstract operations that are executed to solve a specific problem - language/API agnostic. – Demian Brecht Oct 01 '11 at 15:30
  • He was talking about datastructure and algorithm. what I meant to say was, most of the time, chances are there is an API already covering your needs. I've seen so many time ppl writing hundreds of LOC to build an algorithm that the API already does better. In other words, before looking for an algorithm to solve an issue, look at the API. – xsace Oct 01 '11 at 17:12
  • Couldn't agree more then :) – Demian Brecht Oct 01 '11 at 17:15