This post explains about design guidelines for developing class libraries that extends the .NET Framework. Following design guidelines provides benefits of consistency and unified programming model for developers.
Naming Conventions for Casing Identifiers
There are two different styles in Casing Identifiers
- Pascal Casing â€“ The first letter in the identifier and first letter of subsequent word are capitalized. DateOfBirrh
Use Pascal Casing for following types
- Public member
|Read Only field||Pascal||RoleValue|
for the two character acronyms, capitalize the both characters in the word
If the acronym contains more that three characters then capitalize first character of word
- Camel Casing â€“ The first letter of an identifier is lowercase and first letter of subsequent word are capitalized. dateOfBirth
Use Camel Casing for parameter names
Parameter Camel typeName
If the parameter contains more than three characters in acronym then use following style
- Upper Case â€“ All letters in the identifier are capitalized. IO
Guidelines for Naming types and members in Class Names
- Use readable names for elements in the class library.
- Do not use underscores or special characters
- Do not use Hungarian notation â€“ it is a method of using data types as prefix for identifier names.
- Avoid using keyword names for your identifiers
Guidelines for Naming Namespaces
The namespace name should represent the functionality made available by types in the namespace. For example System.Web contains type that enables browser\server communication.
General Format for NameSpace is
1. Use Plural namespace names wherever necessary
2. Do not use the same name for a namespace and a type in that namespace
Guidelines for Classes, Structs and Interfaces
In General type names are noun phrases, choose names that identify entity from developer perspective.
- Do not give class names a prefix such as C
- End the name of the derived class with the name of the base class
- Prefix the interface names with letter I
- Consider using letter T for generic type parameters example: IDictionary<Tkey,Tvalue>
- Add suffix Exception to types that inherit from System.Exception
- Do not add the suffix Delegate to a delegate
- Add suffix Stream to the types that inherit from System.IO.Stream
Guidelines for Type Members
Types can contain the following kinds of members:
Give verb phrase for method names. Verb can describe the action of method makes it easier for developers to understand what the method does.
- Use Noun phrases for giving property names.
- Name EventHandlers with the event handler suffix
- Name event argument classes with the EventArgs suffix
- Use Pascal case for naming the field names
- Do not use any prefix for field names
Please follow the link for detailed guidelines for designing class libraries
|Share this post :|
Good One! Liked the jist of all guide lines.
Explaination of technical reasons for some of the guidlines should been included!!!
Thanks. I do not see any technical reason to follow the guideline as it just makes our life more easier in enterprise world…
Thanks lot for valuable ideas