Seven Pillars of Pretty Code

By | April 21, 2010

The essence of pretty code is that one can infer much about the code’s structure from a glance, without completely reading it. I call this “visual parsing”: discerning the flow and relative importance of code from its shape. Engineering such code requires a certain amount of artifice to transform otherwise working code into working, readable code, making the extra step to leave visual cues for the user, not the compiler.

Code changes should blend in with the original style.

Keep columns narrow. Just as with books and magazines, code should be narrow to focus the gaze.

Two or more pieces of code that do the same or similar thing should be made to look the same. Nothing speeds the reader along better than seeing a pattern.

Overcome Indentation: The left edge of the code defines its structure, while the right side holds the detail. You must fight indentation to safeguard this property. Code which moves too quickly from left to right (and back again) mixes major control flow with minor detail.

via Whitepaper: Seven Pillars of Pretty Code.

One thought on “Seven Pillars of Pretty Code

  1. Pingback: Webs Developer » Perforce Software: Seven Pillars of Pretty Code

Leave a Reply

Your email address will not be published. Required fields are marked *