According to the dictionary, "standard" stands for “something considered by an authority or by general consent as a basis of comparison; an approved model.” Now you may ask why we need to complicate our lives with the adoption of some coding standards. The answer to this question lies in the following pages.
Coding Standards - A Taste of Standards (Page 3 of 5 )
The time has come to actually demonstrate some of the standards so you can better understand their usefulness and the advantages of a standardized code snippet. Here we go...
There are two types of naming standards accepted - Pascal casing and Camel casing. Each of them is recommended for a few situations, but before we venture into that, take a look at the differences between them.
Pascal casing -- First character of all words are upper case, while other characters are lower case.
Camel casing -- Each word has its first character upper case, except the first one, while the rest of the characters are all lower case.
YourName // Pascal casing
yourName // Camel casing
Use Pascal casing for class names, method names, and file names. Camel casing will be used for variable names, method parameters, and with an I prefix in the case of the interfaces. This way when you see a name without its declaration, you should already know what you are dealing with. As a side note, we can add that the Hungarian notation shouldn't be used anymore for variable names. Microsoft gave up on this at the introduction of .NET; instead, the Camel is preferred.
Always -- and I mean always -- figure out and use a meaningful name. When someone looks at it, s/he should already know its purpose. Do not use single character names; however, this rule can be violated in the case of the index loop variables. In any other situation a meaningful and self-explanatory name is the nicest way. For example, defining a variable that will hold a book's title as BookTitle is more advisable than naming it m23. The first path will result in code that is instantly perceived, even after ten years. Also for identifying a member variable quickly, use the ' _ ' underscore character in front of it, so logically it won't appear at any local variables.
The use of prefixes is also a good thing. Insert the Is prefix in front of a Boolean type to indicate its type, and if you're using a user interface, then use the appropriate prefix for it. Look at some examples for these situations:
string _BookTitle; // and not ->> string m23;
int index; // for a local variable
for(int j=0;j<index;j++); //here the single character usage is permitted