Think Like a Programmer

Need to wrap your head around the craft of programming, not just understanding the technology? This book might help.

Programming – real programming – isn’t just about little monkeys madly pounding out code. It’s about solving problems. Big problems, such as how to navigate a spaceship to Mars. Littler problems, like how one of said monkeys can snag a banana that’s sitting just out of reach outside its cage. Problems with profound answers like 42.

V. Anton Spraul has taught programming for 15 years, and he noticed that people who may be able to generate code like maniacs can have trouble making that code do what needs to be done to solve a problem. Those developers have the syntax down cold; it’s the problem-solving skills that need tweaking. That’s what he set out to do in Think Like a Programmer: An Introduction to Creative Problem Solving (henceforth referred to as TLAP).

Problem solving, Spraul explains, uses a different part of the brain. Where learning programming syntax is an analytical left brain activity, writing an original program to solve a problem engages the creative hemisphere. Most programming books focus on syntax and semantics, perhaps throwing in some cookbook-style solutions. There’s not a ton of creativity in the mix.

Spraul takes another tack. He shows how to break down and analyze a problem, then how to build the code to solve it. He says in his introduction, “This book isn’t going to tell you precisely what to do; it’s going to help you develop your latent problem-solving abilities so that you will know what you should do.”

That doesn’t mean there’s a shortage of code in TLAP. There’s a lot, mostly in C++, with a few segues into pseudocode. Spraul makes it clear at the beginning that he assumes the reader has a grasp of the basics of the language, although he does toss in some explanatory matter here and there to refresh one’s memory. I’m no C++ guru, and was still able to follow the examples nicely.

Chapter 1, however, doesn’t contain a scrap of code; it’s all about solving problems. In fact, it should be required reading for anyone who has to figure something out. It lays out problem-solving strategies, with examples, and, like every chapter in the book, ends up with some exercises to try. And no, the answers are not in the back of the book. The point is the journey, not the destination.

Chapter 2 eases you into the programming gently with some simple puzzles using basic C++ constructs, but you spread your wings in future chapters, working with arrays, classes, recursion and code reuse. If you draw a blank on one or more of those topics, you might want to pick up a C++ manual and keep it handy. The final chapter brings it all together in a whimsical example: writing a program that cheats at Hangman. The wrap-up provides sensible advice to beginner and veteran alike.

This is not a programming manual. It doesn’t go into style, and I don’t think there’s a single comment in any of the code (very bad form). But this book is not meant to be a programming manual. It teaches mental skills that can be used to create programs that solve problems – and, indeed, Spraul recommends readers learn by doing, not just read the text and skip the exercises.

You’ll want to read TLAP through from start to finish, not skip around, because each chapter builds on previous work, and sometimes reuses concepts or code from earlier chapters. At 232 pages, including index, it’s not a tough read, but if you sit down and work the examples, it’ll take a while to get through.

It’s worth every minute.

Think Like a Programmer: An Introduction to Creative Problem Solving, by V. Anton Spraul. No Starch Press, 2012. ISBN: 978-1-59327-424-5. $34.95.


Lynn Greiner has been producing words and code for well over 20 years as an IT pro and freelance writer. Follow her on Twitter at @lynngr.

See also:



By submitting this form, you agree to our
Terms of Use and Privacy Policy

Thanks for Subscribing

Keep an eye on your inbox for more great content.

Continue Reading

Add a little SmartBear to your life

Stay on top of your Software game with the latest developer tips, best practices and news, delivered straight to your inbox