Friday, February 19, 2010

Some C# Coding Standards Should follow

Coding standards


  • Ø                          Naming Convention
1.       Use Pascal casing for Class name, Methods, Properties etc
                  Public void DisplayName()
                   {
                    }

2.       Use Camel casing for variables
string customerName
Int customerId

3.       Don’t use Hungerian notation
 string m_sName;
Int nCount;


  • Ø                      Always use meaningful names for variables, properties, Methods etc.
Like:- string customerName
Avoid :- string cust_Name


  • Ø                   Do not use underscore ( _ ) for local variables

  •                          Prefix Boolean variables, properties and methods with “is” or similar prefixes.

Private bool isFinished;


  • Ø          Namespace names should follow the standard pattern

...


  • Ø                   File name should match with class name.

For example, for the class HelloWorld, the file name should be helloworld.cs (or, helloworld.vb)


  • Ø               Always use Pascal casing in filename.


  • Ø             Don’t use variables like i,j in loop. Always use meaningful names

Wrong approach:
For(int i=0; i<10; i++)
{
}

Right approach:
For(int count=0; count<10; count++)
{
}

  • Ø                 Always put Comments for classes, functions, properties etc.

///Summary
/// description of class,methods
///created by : user
///created on : date
///last modified by : user
///last created on : date



No comments:

Post a Comment

Put your comments here

Motivational qoutes

पूरे विश्वास के साथ अपने सपनों की तरफ बढ़ें। वही ज़िन्दगी जियें जिसकी कल्पना आपने की है।