(as of Nov 05, 2023 10:09:18 UTC – Details)
This philosophy-of-programming guide presents a unique and entertaining take on how to think about programming. A collection of 21 pragmatic rules, each presented in a stand-alone chapter, captures the essential wisdom that every freshly minted programmer needs to know and provides thought-provoking insights for more seasoned programmers.
Author Chris Zimmerman, cofounder of the video game studio Sucker Punch Productions, teaches basic truths of programming by wrapping them in memorable aphorisms and driving them home with examples drawn from real code. This practical guide also helps managers looking for ways to train new team members.
The rules in this book include:
As simple as possible, but no simplerLet your code tell its own storyLocalize complexityGeneralization takes three examplesWork backward from your result, not forward from your codeThe first lesson of optimization is don’t optimizeA good name is the best documentationBugs are contagiousEliminate failure casesCode that isn’t running doesn’t workSometimes you just need to hammer the nails
From the Publisher
From the Preface
Welcome to The Rules of Programming, a set of easy-to-remember and easy-to-apply Rules that will help you write better code. Programming is hard, but following the Rules makes it a little bit easier.
Here are some tips on reading the book:
I hope you enjoy what follows! I think you’ll discover a few useful thoughts that help you sharpen your programming skills.
The Story of the Rules
The Rules of Programming were born of exasperation.
I’d spent about a decade running programming teams at Microsoft, then cofounded the video game company Sucker Punch in 1997. Both companies have been successful—in large part because of their ability to recruit and develop top-notch programming teams. At Sucker Punch, that’s led to a 25-year run of successful games. There were the three Sly Cooper games, which let kids of all ages experience the thrilling life of the master raccoon thief Sly Cooper and his pals. There were the five inFamous games, which gave gamers superpowers and the choice to use them for good or evil. And then there’s what is to this point our magnum opus, Ghost of Tsushima, where gamers play a lone samurai fighting back against the 1274 invasion of Japan.
A big part of the recruiting strategy at both Microsoft and Sucker Punch has been hiring smart young programmers, then training them in the ways of professional developers. This practice has been undeniably successful, but it also leads to a particular flavor of frustration.
I kept running into one problem over and over again. We’d bring a new programmer onto the team, often someone fresh out of college. I’d review some new feature they planned to introduce into the code, usually to solve a very simple problem—only to discover that they’d written code that attempted to solve a much bigger problem, one that included the very simple and concrete problem as a small subcase.
Aargh! We didn’t need that bigger problem solved, certainly not right now! Invariably, the solution to the bigger problem was a mediocre solution to the simple problem we did have—more complicated to use, more complicated to understand, and capable of hiding a lot more bugs. But just saying that in the code review—that we didn’t need the bigger problem solved, that they should only try to solve problems they understand—was ineffective. They kept doing it.
Out of frustration, I put my foot down. “OK,” I said. “Here’s the new rule. Until you have three examples of a problem, you’re not allowed to write a general solution.”
To my surprise and delight, this actually worked! Turning the general philosophy into a specific rule with specific criteria was an effective way of getting the message across. Sure, most of our new programmers made the premature generalization mistake once, but the rule helped them avoid making it again. It also helped them recognize when it was time to generalize. Fewer than three examples? Don’t generalize. Three or more? Start looking for opportunities.
The rule worked because it was easy to remember, and the situations where it applied were easy to recognize. When coders could see that they had started moving past the bounds of the well-defined problem at hand, they could take a step back, count the number of concrete examples of that sort of problem they’d run into, and make a better decision about whether to generalize or not. They wrote better code.
So, bit by bit, what was once a single rule grew into a list of rules: the Rules of Programming described in this book. They represent many of the most important aspects of Sucker Punch engineering culture: the things that we believe have led to our success, the ideas that new coders on the team need to absorb to be effective. The things that even senior coders like me need reminding of at least once in a while!
Each of the chapters that follows describes a Rule, with plenty of examples to illustrate the thought behind it. After reading a chapter, you should have a clear idea of the coding practice the Rule encourages and the situations where it applies.
Publisher : O’Reilly Media; 1st edition (January 17, 2023)
Language : English
Paperback : 343 pages
ISBN-10 : 1098133110
ISBN-13 : 978-1098133115
Item Weight : 1.1 pounds
Dimensions : 6 x 0.75 x 9 inches