C# Coding Standards and Best Programming Practice Part-2

March 26, 2013 // In: C#, Sharp Coders

coding standards and programming practice2 300x224 C# Coding Standards and Best Programming Practice Part 2

11. Class & Method Names

Use Pascal casing for class names and method names like in following  code example

 12. Variable Name

For variables use camel notation, avoid Hungarian notation like in the visual studio 2000.
In camel notaion a variable is declare with first lower case letter and afterwards, every first character of a word is uppercase. For example “totalCount” is in camel notation form.

Do not use abbreviations. Use name, address, salary etc. instead of nam, addr, sal

Do not use single character variable names like i, n, x, etc. Use names like index and temp.

13.  File Name

File names should match the class name. Though C# does not force for this rule as in java.

14. Methods

The method’s name should tell what it does.

A method should do only “one job.” Do not combine more than one job in a single method, even if those jobs are very small.

15.  Variables

Use language specific data types and not the alias defined in system name space like int,long and not System.Int32 or System.Int64

Use Meaningful, descriptive words to name variables. Do not use abbreviations.

Good:

Not Good:

 

C# Coding Standards and Best Programming Practice Part-3
C# Coding Standards and Best Programming Practice Part-1
You might also likeclose