Know Your Audience

To write effective source code, it’s important to know who you’re presenting it to. If you’re going to confuse someone, you’d better know who deserves the apology. There are, in fact, three audiences for our source code:

Ourselves

My handwriting is so bad that sometimes even I can’t read it. It’s practically useless unless I concentrate on writing clearly. It’s the same with code. You have to be able to read what you’ve written immediately after you write it, but also perhaps years later when you come back to it. Who would have expected to come back to archaic (relatively speaking) COBOL code to fix a Y2K bug?

The compiler

The compiler doesn’t care what your code looks like, as long as it doesn’t have any syntactic errors. The ...

Get Code Craft 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.