10 Style
Style and naming conventions can be a controversial issue. The primary goal of establishing naming conventions is to make code easier to read. Source code is typically more often read than written. Programs should be written as clearly and consistently as possible. Consistent use of naming conventions and consistent layout of source code is a sign of high-quality work. A few recommendations follow.
10.1 Naming Conventions
Use short, common, and non-abbreviated names.
Use abbreviations sparingly.
Use very short variable names only as local variables, and if their meaning is clear from the context.
Use i, j, k as loop indices.
Do not make the type name part of the variable name, e.g., center rather than center-point.
Use plural for collections of items, e.g., names rather than name-array.
Use lower-case function, variable, and file names.
Use dash as a word separator, e.g., hours-to-wages. Note that this is a PostFix convention. C often uses underscores (e.g., hours_to_wages) and Java often uses camel case (e.g., hoursToWages).
Use CAPITALIZED-WITH-DASHES for constants.
Use CamelCase with an upper-case first letter for custom-defined type names, e.g., TrackingOrder.
Avoid l as a variable name and O as a type name as they are easily confused with 1 and 0, respectively.
10.2 Coding Style
Properly indent code. This is extremely important for readability.
Consistently indent code. Do not mix tab characters and spaces. The typical tab width is 4 spaces. Using spaces avoids problems with different editor settings.
Use empty lines to visually structure blocks of code.