How do you break down a problem?

closed account (yR9wb7Xj)
I always have a hard time breaking down a problem when it comes to finding a solution. A lot of people tell me start with what you know and work your way up where it's a challenge. I want to know what do you guys do when it comes to this, and how do you do it? Thanks!
Last edited on
I start with what I don't know.
Last edited on
It's really hard to explain 'how'. I think it's just a skill that you get with practice.

The thing is you probably already know how to do instinctively. If I were to ask you to break down the process of making a sandwich into 10 steps, would you be able to do it? Probably.

With programming, or really anything else, it's all about taking a large problem and asking "okay, what are the smaller steps I need to do to complete this larger problem". And if those steps themselves are large, then you keep breaking them down into smaller steps until they are simple enough to tackle.

Then you just do them one at a time.
closed account (yR9wb7Xj)
Thank you guys!
One of the problem is that, if you only have bought sandwiches so far, you may not know all the ingredients.
You may need to open it to know which ingredients it's got, or, if you feel creative enough, you can try making it anyways, with your own cheese or so on.
--
One of the problem is that, if you only have used applications (or libraries) so far, you may not know how they work.
You may need to check the source code to know how it works, or, if you feel creative enough, you can try making one anyways with your own knowledge.
Sorry to drop in, but how would I solve a coding problem?
It depends.
Something that my professor told me that's really helped is don't take anything for granted.

What he meant by that was no matter how small, a detail is a detail. Going back to the sandwich example, you know in your head you have to get cheese, spicy mayo, some meat, bread, etc.

Question is, the computer doesn't know. So how do you fetch those ingredients? Then, what's the process of telling the computer to put it all together, AND in the right order (also this is where knowing the concept of sorting becomes important). You have the ingredients, how does the computer know you have to fetch them one at a time?

But...I still suck. So who knows, maybe it's just me.
genellewhite wrote:
Sorry to drop in, but how would I solve a coding problem?


The same way you solve any problem!

1. Determine Goal. If goal is immediately addressable, address it and return;
2. Break into subgoals
-Observe (if observable)
-Theorize (if it can be conceptualized)
-Simulate (if it can be simulated)
-Extrapolate (in otherwords, make logical connections)
-Interpolate (steps between x and y)

-What actions MUST be accomplished
-What environmental parameters must be in place
-What must be prevented
-What must be changed
-What must be created
-What must be destroyed
-What must be learned

*Continue this pattern of what questions, hopefully with questions that are relevant to the situation.*

Instead of asking yourself "How do I" try to think of "What is" questions. Generally the process is similar to minesweeper, if you find an opening it will open more possibilities once it's accomplished. If you have no openings look at the plausible steps and try them, luckily the mines aren't permanent on this stage.

Stagefright is easy in programming, and goal making/accomplishing in general. Don't simply fail to act because you aren't sure of your next step. Don't rely on motivation to fulfill your dreams, rely on willpower. Reward yourself for action, punish yourself for inaction. The more you practice goal setting, acting through willpower, and breaking down problems the better you'll get at it. Don't let yourself slide by in problem solving the way you always have, think about the methods you use and improve them, you can then take that reflection and begin to improve other areas of your life, one that very few people consider is the method you use to actually think (there are numerous ways you can improve your thought power, thereby increasing every other aspect of your existence)

...


I need to stop, sorry. I'm actually writing a book on these topics, I have a lot to talk about :)
Last edited on
Go read the Pragmatic Programmer. It'll really change you approach problems.
Some people talk about top down design and some talk about bottom up design, but I prefer to think of as peeling an onion: you work from both directions, starting with what you know and working towards the middle.

It often helps to start with the data. What data do you need? What operations will you have to perform on it? Sketch that out. Once you have to data and the operations, the higher level stuff will fall into place.

One other method that I find very helpful: the purpose of your functions and methods is NOT to do the work. The purpose is to make doing the work easy. If you think of things this way, you'll write code that is flexible. A simple example: don't write a function/method/ that prints your data to cout. Write a function that takes a stream as a parameter, then call it with cout.
What is the Pragmatic Programmer,and where can I find it?
Thank you all for the help
closed account (yR9wb7Xj)
All I did to find it was google it, but here you go
http://www.amazon.com/The-Pragmatic-Programmer-Journeyman-Master/dp/020161622X
While you're at it, you get this too.
http://www.amazon.com/Think-Like-Programmer-Introduction-Creative/dp/1593274246/ref=sr_1_1?ie=UTF8&qid=1442616783&sr=8-1&keywords=Think+Like+A+Programmer
Last edited on
Thanks SO MUCH
Topic archived. No new replies allowed.