Write Beautiful Code

Translated to our world of software, the good genes theory means the absence of special cases. Beautiful code has a consistent level of expression. Just as deviations from the mathematical averageness makes a face less attractive, so does any coding construct that deviates from the main style of your application.

These constructs signal bad genes in our programs because they make it harder to form a mental model of the program. That’s just the way your brain works; when presented with inconsistencies and conflicting representations, your brain selects one of the stimuli at the price of the other. You can switch between them, but it’s going to be expensive.

That means as soon as you break the expectations of someone reading ...

Get Your Code as a Crime Scene now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.