Software Engineers Handbook/Supporting Processes/Coding Standards

From Wikibooks, open books for an open world
< Software Engineers Handbook
Jump to: navigation, search

Here is the wikipedia entry for coding standards.

Coding standards generally contain a set of conventions for a specific language. Items typically covered are:

  • Naming conventions including:
    • how descriptive and long the names should be,
    • what the capitalization scheme should be, and
    • what the postfix and prefix conventions are.
  • Physical organization, such as Definitions shall be located in the header files. and Do not include more than one class in one file.
  • Structure conventions, such as Opening and closing braces shall be located in the same column like this:
{
    {
        // code in here
    }
}
  • Style guides, such as Classes containing pointers shall have a virtual destructor. It is useful to include the reasoning and references for this type of standard.
  • Legacy code guidance, such as When editing existing code, follow the coding naming and structure conventions of the existing code.

C++[edit]

Java[edit]

C[edit]

Eiffel[edit]

Naming conventions[edit]

"Always, always, always use good, unabbreviated, correctly-spelled meaningful names." -- c2: MeaningfulName

Popular naming conventions (naming formats) include:

  • ALL_UPPERCASE_WITH_UNDERSCORES
  • all_lowercase_with_underscores
  • CamelCase
  • uppercaseOnlyInTheMiddle
  • _UnderscorePrefixedCamelCase
  • Camel_Case_With_Underscores

For surprisingly long conversations about naming conventions, see c2: UnderscoreVersusCapitalAndLowerCaseVariableNaming; Wikipedia: CamelCase; c2: CamelCase; and "Underscores vs CamelCase".

Further reading[edit]