Coding Guidelines
To Live By

If you need more than 3 levels of indentation, you're
screwed anyway, and should fix your program.

— Linus Torvalds

by Jason Robert Carey Patterson, last updated Mar 2014 (orig Mar 2004)

The following coding guidelines checklist is by no means exhaustive, but has proven to be useful for many programmers. It has been built up over more than 30 years of programming experience across a myriad of different systems and languages. While not impossible, it would be difficult for a piece of code to pass this checklist and yet still not be "good". Naturally, as with all things, sensible judgment should be used when applying this checklist, as not every point is valid for every possible situation.

NOTE: There is no attempt to explain the "whys" of each point here – for that, you should search the web for more detailed articles, of which there are many. This list is purely intended as a brief, concise checklist for professional programmers to run through very quickly, typically right before a piece of code is finally committed to a version-control system and declared finished.

General Approach

New Files

File Top Matter

Code Formatting

General Code Quality

Comments

Memory Management

Error Handling

Security

Performance

Parallelism, Threading & Locking

C Specific

C++ Specific

Objective-C Specific

Java Specific

JavaScript Specific

PHP Specific

Perl Specific

UNIX Shell Specific

Documentation

Anything More I Could Do?

Remember Priorities