Your Code as a Crime Scene, Second Edition by Adam Tornhill

Your Code as a Crime Scene, Second Edition by Adam Tornhill

Author:Adam Tornhill
Language: eng
Format: epub
Tags: Pragmatic Bookshelf
Publisher: The Pragmatic Bookshelf, LLC


Use Beauty in Code

Beauty, being the absence of ugliness, translates well to our software world, too. Beautiful code has a consistent level of expression that’s easy to follow. Just as deviations from the mathematical average make a face less attractive, so does any coding construct that deviates from the main style of your application or introduces accidental barriers to understanding the code. Examples of such issues include special cases and the code smells covered in Chapter 6, ​Remediate Complicated Code​.

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

That means you’ve introduced a cognitive cost as soon as you break the flow of someone reading your code. This cost makes your programs harder to understand and riskier to modify. A broken code reading flow is to blame for many bugs.

Beauty Influences Sentencing



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.