Saturday, July 12, 2014

The Ten Commandments

I've seen more than one list of "programming commandments", but for some reason they are always aimed at a specific subset of programming (e.g. The Ten Commandments of Programming in .Net), plus they always seem pretty advanced.
No, the true ten commandments need to be universal, and absolutely basic.
Here's the ones I came up with:

1 Thou shalt indent.
2 Thou shalt not comment the obvious.
3 Thou shalt give thy functions short, informative names.
4 Thou shalt split any function that contradicts the 3rd commandment.
5 Thou shalt spend a few hours studying thy language's basic features.
6 Thou shalt keep it short.
7 Thou shalt keep it simple.
8 Thou shalt minimize branching.
9 Thou shalt minimize nesting.
10 Thou shalt avoid code duplication where possible.

These ought to be the absolutely most basic guidelines for writing good, clear code. Forget about conventions, methodologies, paradigms and patterns; the ten commandments should be a part of you long before you even hear those terms. Whether you're dealing with classes in Java or pattern matching in Haskell, sticking to these rules is guarantee to make your code more readable than otherwise, which you'll be thankful for as soon as you have to debug it (which is sooner than you think!).

No comments:

Post a Comment