Abbreviations
Do not use of shortenings or constractions as parts of identifier names, For example, use GenWindow rather than GetWin.
Namespaces:
<Company>.<Technology>[.<Feature>][.Design]
Don't use organizational hierarchies as the basis for namcespaces.
Class Naming:
Do not use any type of class prefix such as C.
Do not use the underscore character.
Interface Naming:
Do prefix with the letter I to indicate that the type is an interface.
Enum naming:
Do not use an Enum suffix on enum types.
Do not use a prefix on enum names.
Method Naming:
Do name methods with verbs or verb phrases.
Property Naming:
Consider having a property with the same name as a type.
public enum Color {...}
public class Control {
public Color Color { get set }
Event Naming:
Do name event handlers(delegate types) with the EventHandler suffix as in the following example.
Do use two parameters named sender and e.
Do name event argument classes with EventArgs suffix. For example, public class ClickedEventArgs
Case Sensitivity:
Do not use names that require case sensitivity.
void foo(string a, string A)
Type:
If needed, do use universal type names, like SByte, Byte, Int32, String, etc.
int ReadInt32(); is better than int ReadInt();
Class Members:
Do preserve the previous value if a propertye setter throws an exception.
Do not use Hungarian notation.
Do allow properties to be set in any order. In addition, the developer can set a property to null to indicate that the value is not specified.
It is recommended components raise Property Changed events
Event Usage:
Do use the "raise" terminology for events rather than "fire" or "trigger" terminology.
Constructor type:
Do provide a constructor for every type.
Field Usage:
Do use const fields for constants that will NEVER change.
Do use public static readonly fields for predefined object instances.
Do not include a prefix on a field name, for example, 'g_', 'm_'.
Parameter Usage:
Do check arguments for validity.
Base Class:
TOdo:
Sealed Class:
Do use sealed classes if there are only static methods and properties on a class.
Struct:
It is recommended to use a struct when
Act like primitive types
Have an instance size under 16 bytes
Are Immutable.
Value semantics are desirable.
Do not provide a default constructor.
Do not depend on a constructor for yoru struct being called for each instance.
Enum Usage:
Do favor using an enum over static constants.
Do not use an eunum for open sets.
Do use the System.FlagsAttribute custom attributes for an enum only if a bitwise OR
operation is to be performed on the numeric values.
Interace Usage:
To be continued...
THIS POST IS PROVIDED "AS-IS" WITH NO WARRANTIES AND CONFERS NO RIGHTS. Build time: Sun 03/30/2008 . ©2007 Dalun Software. All rights reserved. Back to Article List