This style of Every Programmer Should Understand This blog post has been cropping up a lot lately. I disagree with this particular one. Let me try my own hand.
Breaking problems down is the single most important skill of a programmer. I have in mind four different angles of “breaking down”.
First, breaking problems down into their more basic or general parts. As an example, almost all business applications can be re-imagined as “I need a database that we can query and update, while only dealing with relevant business details, and avoiding all the nasty computer bits.”
Second is breaking problems down into sub-problems. If somebody asks you to reverse a linked list, you can do this very fancifully in-place in memory in O(n) time and whatnot. Or you can create a new list, pull items off the back of the first list, and push them onto the new list. This second solution is simpler, more general, and likely slower and offers poorer memory utilization. But at least you have smaller and simpler problems, rather than one larger and more complex problem.
Thirdly, breaking problems down linearly into steps that, when taken, will lead to an acceptable outcome. The classic example of “make a sandwich” can be broken down into multiple individual steps that, done one after the other, yield a sandwich. First get some bread, mayonnaise, turkey, and a knife. Spread the mayo on the bread using the knife. Etc.
Finally, breaking a problem down into all of it’s possible twisty paths. Few things in life proceed down a happy path for long. Taking care to follow the “what if” scenarios and having some kind of mitigation strategy is key. Even throwing up your arms and shouting “I’m out!” is better than not considering unfortunate circumstances at all.
An astute reader will recognize that none of the above really has anything at all to do with programming. This is just how you approach any challenge in life.
Decide what the outcome should really be.
Break down the distance between the present condition and the desired outcome into smaller bits than can be managed more easily.
Proceed with a course of action that will achieve each goal.
Plan ahead for the inevitable setbacks along the way.
Written 2015-07-07.