My Personal Coding Standard

So I wanted to share with the world my personal coding standard. This is the coding standard I use everyday when I develop software.

Naming

  1. Never abbreviate, never.
  2. Prefix private fields with the underscore character (_). This will be the ONLY time you will use the underscore character when naming.
  3. Never use the underscore character for namespace, class, method, enum, enum value, event, read-only, const, interface and property names.
  4. Use Pascal casing for namespace, class, method, enum, enum value, event, read-only, const, interface and property names.
  5. Use Pascal casing for abbreviation like HTML should be Html. Ex. XML should be Xml.
    1. The only exception is two character abbreviations like “IO” and they should always be capitalized.
  6. Use camel casing for local variables and method arguments. Ex. isRunning, phoneNumber
  7. Prefix component / control variables with the class name. Ex. LabelName, TextBoxAddress
  8. Name interfaces with the “I” prefix. Ex. IConfigurable, IExtendable
  9. Suffix exception classes with “Exception”. Ex. InputInvalidException, TypeNotFoundException
  10. Use descriptive naming.
    1. Avoid one character variable names, such as i or t. Use index or temp instead.
    2. Simple “for” loops are the only exception to one letter variable names.
    3. Never use Hungarian notation for public or protected members. Ex. strName, intNumUsers
    4. Do not abbreviate works such as using num instead of number. See General 1.
  11. Avoid fully qualified type names. Use the “using” statement instead.

Style

  1. Maintain strict indentation. Always use “TAB” for indentation and never use spaces.
  2. All comments should pass spell checking. Misspelled comments indicate sloppy development.
  3. All methods should be separated by only one blank line.
  4. Always place an open curly brace “{“ on a new line.
  5. Always use curly brace scope for “if”, “for”, etc… statements, even it contains a single statement.
  6. Avoid multiple classes in one file. Always put clases, structures in their own file.

 

More to come…