Emerald Hand Wiki

Coding conventions

Modified: 2008/09/04 12:21 by Ornus - Categorized as: Development

Edit

.NET conventions

Edit

Naming

  • all namespaces, classes, public members (methods and properties), constants have PascalCaseNames : Namespace.Class.PublicProperty.Method()
  • all fields, parameters and variables have cameCaseNames: _field = variable = parameter
  • all fields (which are always private) start with underscore: _privateField;
  • method names are verb oriented: DoActionOnData(), ShowDialog()
  • give descriptive names, no abbreviations: columnIndex instead of i, etc. only exception are simple loops.
  • unit test names follow Method_InputParameters_ReturnedValueOrExpectedActions naming format: Add_TwoAndTwo_ReturnsFour()
  • place each scope operator ({}) on a new line
  • explicitly declare accessors: public var _field; instead of var field
  • when in doubt follow the same convention as .NET coding guideline and C# Coding Standards.

Edit

Declaration

  • all fields are either private are protected. all fields to be accessed from the outside are wrapped in a public property.
  • no internal declarations (they're generally useless), unless there's a really good argument to make some class / member internal

Edit

Database conventions

Edit

Naming

Edit

Declaration

  • each table has AutoID column with automatically incrementing int primary key

Edit

Documentation

  • Change log in SVN log - If you add new methods to public API for consumption, add them to the commit description. Other people can pick it up. Use SVN log to document new examples, etc.
  • Method documentation - What method does, takes, returns, remarks, exception thrown are documented at method declaration with XML comments. Resharper can show all this using Quick Documentation keyboard shortcut (Ctrl+Shift+F1 for VS Scheme and Ctrl+Q for older Resharper 2 Scheme)
  • Examples - Examples of how to use method can be added either to the method docs. A separate example can be added to the test project, to a file ending with "...Examples.cs" Probably both.

Copyright © 2006-2008 Emerald Hand, Inc. All rights reserved.
Powered by ScrewTurn Wiki version 2.0.34. Some of the icons created by FamFamFam.