How to Think Like a Programmer by Anton Spraul

  • Author: Anton Spraul
  • Get the Book: Amazon
  • Rating: 7/10

High level summary

When you learn how to program, you quickly find out that writing code isn’t the difficult part. You can look something up on Google and 9 times out of 10 someone on Stackoverflow gives some sort of solution. No, the real difficulty with programming is coming up with a solution to a complex problem. Most programming tutorials teach you the basics of code, but never talk about problem solving (most of them go like this). When you try to create something useful, you end up being stuck because you don’t know how to get to a point where you can actually start writing code.

That’s the problem this book tries to solve. This book takes you through the process of how to take a problem that looks complex and break it down in a way that you can solve it. It provides code samples and explains why you would do certain stuff.

Notes

  • Expert problem solvers can quickly see the similarities between problems even if the specifics aren’t the same.
  • If you don’t know all the possible actions you can take, it becomes hard to solve a problem.
  • Spending time upfront breaking down the problem into smaller chunks is going to make it easier later on. Even if you don’t find a solution it can help you understand the problem better.
  • In order to solve a problem you sometimes have to focus on the most constrained part — the part with the least amount of wiggleroom — and work your way back. This part simplifies your options.
  • General problem solving techniques:
    • Always have a plan. The act of coming up with a plan is the valuable thing here. It forces you to lean about the options, constraints, and problem in general.
    • Restate the problem. This is like looking at the problem from different angles. One way of doing this is using more general terms to describe a problem.
    • Divide the problem. Instead of finding a solution for everything all at once, start with a very small part.
    • Start with what you know. Do the things you already know how to do and expand from there.
    • Reduce the problem. Make the numbers smaller or reduce the amount of steps your trying to solve. ex: instead of processing a list of 100 items, process 1 item first.
    • Look for analogies. Have you solved a similar problem somewhere else?
    • Experiment. Consciously try out small scale solutions to get a better understanding of the problem.
    • Don’t get frustrated. Being able to handle frustration is key when solving problems.