My Coding Style
My coding style tries to minimize complexity. The main motivation is that well-styled programs are easier to understand and are more extensible.
All-Languages
Minimize horizontal complexity, that is, the depth of nesting of control structures, as well as the total line length. No line of code should extend past 100 characters.
Minimize vertical complexity, that is, the code length in lines. If you have many lines of code, you may want to consider splitting into multiple units.
Minimize the number of parameters. Consider using a structure to pass the information
Minimize the number of looping blocks, the number of contained instructions, and the number of nested levels
Minimize the number of consecutive conditionals
Variables
Minimize the number of variables, mostly by inlining variables which are used only once
Minimize the visibility of variables and other identifiers by defining them at the smallest possible scope which also minimizes the variable life time.
Minimize the accessibility of variables, by preferring private variables
Minimize variable name length, but do use complete words and not acronyms. Acronyms are acceptable only when generally accepted by the industry
Minimize the use of arrays by replacing them with collections provided by standard and of-the-shelf libraries.
Control
Minimize the use of conditionals by using specialized constructs such as
ternarization and inheritance.
Simplify conditionals with early returns
Simplify logic of iterations with early exits (return, break, continue)
C#
For C# language, I have standardized on the Microsoft Coding Standard with one exception. I use the new Code Analysis feature in Visual Studio, Microsoft StyleCop 4.4, and Microsoft FxCop 10.0. Most of my project code either belong to my employer or the client, so I turn off SA1633, SA1634, SA1635, SA1637, SA1638, SA1639, and SA1640. Each of these rules deal with the a “properly formatted file header” containing copyright, file name, summary and company text. I sometimes ignore the Strong-Name and Globalization rules if the project will not be used outside of the en-us locale.
Python
Bash
PHP
Java