"Programs must be written for people to read, and only incidentally for machines to execute." --Abelson and Sussman (Structure and Interpretation of Computer Programs) "When developing code you should always choose readability over convenience. Code will be read many, many more times than it is written..." –-Venkat Subramaniam and Andy Hunt (Practices of an Agile Developer) * 80% of the lifetime cost of a piece of software goes to maintenance. * Hardly any software is maintained for its whole life by the original author. * Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly. --Java.sun.com (Code Conventions for the Java Programming Language) "Rules are for the obedience of fools and the guidance of wise men." --David Ogilvy -------------------- Indentation and Tabs -------------------- * Use 4-columns for all indentation levels. * Use spaces for all indenting; do not use hard tab characters. * Use a text editor that supports variable tab widths and conversion of tabs to spaces (examples have been given for vi and nano). --------------------------------------- Compound Statements (Blocks) and Braces --------------------------------------- * Indent enclosed statements one more level than the compound statement. * The opening brace should be at the end of the line that begins the compound statement OR on the next line, indented to the same level as the compound statement. The closing brace should begin a line and be indented to the beginning of the compound statement. Choose one of the following and be consistent: for (i = 0; i < BUF_SIZE; ++i) { for (i = 0; i < BUF_SIZE; ++i) // one or more statements { } // one or more statements } * Use braces around all statements, even single statements, when they are part of a control structure, such as if-else, for, or while statements. YES *NO* --- ---- for (i = 0; i