Naming standards and basic rules in .net coding

Naming standards and basic rules in .net coding

In this post I am going to share about Naming standards in C#.net with basic rules. It is best to follow the naming standards while programming, in any language.

Thanks to slideshare.net

[slideshare id=5233695&doc=namingstandards-100919103335-phpapp01]

Here is more presentations http://www.slideshare.net/nagaharish_movva/

Slides Content :-

    • Naming convention is a set of rules. Those rules applied in our computer programming.
    • Naming is an important step to improving the clearness, readability, and maintainability of code when many developers are working on same application development.
    • For Well-organized code.
    • To make easier to understand for everybody in the team.
    • To reduce time to understand source code by new users.
    • For better appearance.
    • One important thing, you can improve you value in development.
    • Avoid using identifiers that conflict with keywords (for e.g.:- int, char, string and ….).
    • Don’t use single character for Variable names.
      • Avoid using words like i, j, n, x, t and so on.
      • Give meaningful name like index, count, temp, flag …
    • Don’t use long and meaningless names for variables, to understand in better way. It must short and smart.
    • Don’t create variable with same name like I ndex and i ndex using different case.
    • Follow the standard while creating namespace or package
      • [CompanyName].[TechnologyName].[Feature]
      • For example:
      • Microsoft.Office.Word
    • Write comments.
    • Don’t write more line code in same method, try to separate into small methods. It may useful in feature.
    • Use Tab then more white spaces.
    • Avoid hardcode numbers, use constants
    • User a single space before and after for each operator and brackets.
      • if ( isTrue == true )
      • Note:- Sorry!, I focused on DOTNET
    • Avoid hardcode for strings, try to use resource files. So it will be easy to implement multi-language.
    • Do not use a type prefix, such as C for class, on a class name. For example, use the class name FileStream rather than CFileStream.
    • Do not use an Enum suffix on Enum type names.
    • Is best to avoid using _ in class and interface names mainly.
    • For better understand use Collection word at end of Collection class. For example :- MediaCollection
    • Pascal case :-
      • The first letter in the identifier and the first letter of each subsequent concatenated word are capitalized.
      • For Example G et N ame or S et N ame
    • Camel case:-
      • The first letter of an identifier is lowercase and the first letter of each subsequent concatenated word is capitalized.
      • For Example g et N ame or s et N ame
    • Uppercase:-
      • All letters in the identifier are capitalized. Use this convention only for identifiers that consist of two or fewer letters.
      • For Example System. IO or System.Web. UI
    • It is better to follow those naming style in coding in .NET.
    • So it will become easy to understand yourself and other developers, when any logic errors came.
    • Don’t leave exception catch empty, write code for entry to event logo.
      • For e.g.:- try{ /*…..*/} catch { /*Event logo */}
      • Enjoy while coding…!
    • http://msdn.microsoft.com/en-us/library/czefa0ke%28v=vs.71%29.aspx
    • http://www.asp.net/ajaxlibrary/act_contribute_codingStandards_Naming.ashx for Ajax tool

Thanks,

Naga Harish.

Leave a Reply