… For Better Development Naga Harish Movva [email_address] exception class for switch interface catch while if else names...
<ul><li>Naming convention is a set of rules. Those rules applied in our computer programming. </li></ul><ul><li>Naming is ...
<ul><li>For Well-organized code. </li></ul><ul><li>To make easier to understand for everybody in the team. </li></ul><ul>...
<ul><li>Avoid using identifiers that conflict with keywords (for e.g.:- int, char, string and ….). </li></ul><ul><li>Don’t...
<ul><li>Write comments. </li></ul><ul><li>Don’t write more line code in same method, try to separate into small methods. I...
<ul><li>Avoid hardcode for strings, try to use resource files. So it will be easy to implement multi-language. </li></ul><...
<ul><li>Pascal case :- </li></ul><ul><ul><li>The first letter in the identifier and the first letter of each subsequent co...
Identifier Case Example Class Pascal MyClass Enum type Pascal Day Enum value Pascal Sunday Event Pascal OnClick Exception ...
<ul><li>It is better to follow those naming style in coding in .NET. </li></ul><ul><li>So it will become easy to understan...
<ul><li>http://msdn.microsoft.com/en-us/library/czefa0ke%28v=vs.71%29.aspx </li></ul><ul><li>http://www.asp.net/ajaxlibr...
of 10

Naming standards and basic rules in .net coding

This presentation about Naming standards and basic rules while coding in C#.net, this is best of my knowledge. If any mistakes please let me know .. Thanks for share!
Published on: Mar 3, 2016
Published in: Education      
Source: www.slideshare.net


Transcripts - Naming standards and basic rules in .net coding

  • 1. … For Better Development Naga Harish Movva [email_address] exception class for switch interface catch while if else namespace int string do public
  • 2. <ul><li>Naming convention is a set of rules. Those rules applied in our computer programming. </li></ul><ul><li>Naming is an important step to improving the clearness, readability, and maintainability of code when many developers are working on same application development. </li></ul>
  • 3. <ul><li>For Well-organized code. </li></ul><ul><li>To make easier to understand for everybody in the team. </li></ul><ul><li>To reduce time to understand source code by new users. </li></ul><ul><li>For better appearance. </li></ul><ul><li>One important thing, you can improve you value in development. </li></ul>
  • 4. <ul><li>Avoid using identifiers that conflict with keywords (for e.g.:- int, char, string and ….). </li></ul><ul><li>Don’t use single character for Variable names. </li></ul><ul><ul><li>Avoid using words like i, j, n, x, t and so on. </li></ul></ul><ul><ul><li>Give meaningful name like index, count, temp, flag … </li></ul></ul><ul><li>Don’t use long and meaningless names for variables, to understand in better way. It must short and smart. </li></ul><ul><li>Don’t create variable with same name like I ndex and i ndex using different case. </li></ul><ul><li>Follow the standard while creating namespace or package </li></ul><ul><ul><li>[CompanyName].[TechnologyName].[Feature] </li></ul></ul><ul><ul><li>For example: </li></ul></ul><ul><ul><li>Microsoft.Office.Word </li></ul></ul>
  • 5. <ul><li>Write comments. </li></ul><ul><li>Don’t write more line code in same method, try to separate into small methods. It may useful in feature. </li></ul><ul><li>Use Tab then more white spaces. </li></ul><ul><li>Avoid hardcode numbers, use constants </li></ul><ul><li>User a single space before and after for each operator and brackets. </li></ul><ul><ul><li>if ( isTrue == true ) </li></ul></ul><ul><ul><li>Note:- Sorry!, I focused on DOTNET </li></ul></ul>
  • 6. <ul><li>Avoid hardcode for strings, try to use resource files. So it will be easy to implement multi-language. </li></ul><ul><li>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. </li></ul><ul><li>Do not use an Enum suffix on Enum type names. </li></ul><ul><li>Is best to avoid using _ in class and interface names mainly. </li></ul><ul><li>For better understand use Collection word at end of Collection class. For example :- MediaCollection </li></ul>
  • 7. <ul><li>Pascal case :- </li></ul><ul><ul><li>The first letter in the identifier and the first letter of each subsequent concatenated word are capitalized. </li></ul></ul><ul><ul><li>For Example G et N ame or S et N ame </li></ul></ul><ul><li>Camel case:- </li></ul><ul><ul><li>The first letter of an identifier is lowercase and the first letter of each subsequent concatenated word is capitalized. </li></ul></ul><ul><ul><li>For Example g et N ame or s et N ame </li></ul></ul><ul><li>Uppercase:- </li></ul><ul><ul><li>All letters in the identifier are capitalized. Use this convention only for identifiers that consist of two or fewer letters. </li></ul></ul><ul><ul><li>For Example System. IO or System.Web. UI </li></ul></ul>
  • 8. Identifier Case Example Class Pascal MyClass Enum type Pascal Day Enum value Pascal Sunday Event Pascal OnClick Exception class Pascal FileNotFoundException Note:- Always ends with the suffix Exception IOException here IO is in upper case Read-only Static field Pascal CheckValue Interface Pascal IMyInterface Note:- Always begins with I. Method Pascal GetName Namespace Pascal System.Data Parameter Camel userName Property Pascal CurrentUserName Protected instance field Camel getName Public instance field Pascal GetName Class-Level Private Variables Camel (with Leading Underscore) _recordId
  • 9. <ul><li>It is better to follow those naming style in coding in .NET. </li></ul><ul><li>So it will become easy to understand yourself and other developers, when any logic errors came. </li></ul><ul><li>Don’t leave exception catch empty, write code for entry to event logo. </li></ul><ul><ul><li>For e.g.:- try{ /*…..*/} catch { /*Event logo */} </li></ul></ul><ul><ul><li>Enjoy while coding…! </li></ul></ul>
  • 10. <ul><li>http://msdn.microsoft.com/en-us/library/czefa0ke%28v=vs.71%29.aspx </li></ul><ul><li>http://www.asp.net/ajaxlibrary/act_contribute_codingStandards_Naming.ashx for Ajax tool </li></ul><ul><li>Naga Harish Movva </li></ul>