Skip to Main Content
The Rules of Programming
book

The Rules of Programming

by Chris Zimmerman
December 2022
Beginner content levelBeginner
343 pages
7h 36m
English
O'Reilly Media, Inc.
Audiobook available
Content preview from The Rules of Programming

Rule 20. Do the Math

This isn’t a very math-y book. Sure, numbers pop up in a few of the Rules (like Rule 4, “Generalization Takes Three Examples”, and Rule 11, “Is It Twice as Good?”), but the Rules are more concepts than equations.

It’s sort of surprising that there isn’t more math in computer programming. Computers are just number processing machines, after all. Everything is reduced to numbers for processing—words are sequences of characters represented as numbers, bitmaps are pixels represented by colors represented by numbers, music is a pair of waveforms represented as a series of numbers. You’d think that some of that would leak through—that, as a programmer, you’d be figuring equations at some point. That doesn’t happen very often, though.

Most of the decisions a programmer makes are squidgy. Deciding whether the clarity a lengthy comment would add is worth complicating the flow of logic, say. Choosing between getPriority or calculatePriority as the name for a function.1 Identifying the right time to switch over to a new version of some system.

It’s easy to fall into thinking that all decisions are squidgy, not just most decisions. Some decisions boil down to simple math, though, and you need to recognize them when they pop up. If you don’t, if you forge ahead without doing the simple math, you may be in for a painful realization later on. You may discover that the approach you’ve followed was never going to work, and that you could have saved yourself a lot of time by ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Programmer's Brain

The Programmer's Brain

Felienne Hermans
Design It!

Design It!

Michael Keeling
The Art of Clean Code

The Art of Clean Code

Christian Mayer

Publisher Resources

ISBN: 9781098133108Errata PageSupplemental Content