|
Friday, March 28, 2003
|
|
|
My C# coding conventions I know that Microsoft is promoting Camel-hump notation for variable names, but having written a fair amount of C# code now, I think this is a bad practice. Case sensitivity as a differentiation mechanism just doesn't cut it for me. So here's what I am doing for variables names: 1) Specify full namespaces for non-value types and types as generic variable names
System.EventArgs EventArgs = new System.EventArgs(); MyNamespace.Animal Animal = new MyNamespace.Animal("Cat");
2) Specify full namespaces for non-value types and prefixed types as specific variable names
System.EventArgs TreeViewEventArgs = new System.EventArgs(); MyNamespace.Animal DeadAnimal = new MyNamespace.Animal("Sabretoothed Tiger");
3) Prepending m_ for member variables, s_ for static variables, i_ for input variables, io_ for input/output variables, o_ for output variables.
public class Animal() { static int s_CreatedCount;
private string m_Name;
public Animal(string i_Name) { m_Name= i_Name; ++s_CreatedCount; } }
This technique allows any reader, including myself, to quickly discern information about the variable without having to search for it's declaration. Yes I know that my technique involves more typing, but I believe that the advantage are worth it. Also, let's not forget that IntelliSense helps out a lot.
8:30:13 AM
|
|
|
|
© Copyright
2005
Paresh Suthar.
Last update:
8/19/2005; 3:23:35 PM.
This theme is based on the SoundWaves
(blue) Manila theme. |
|
March 2003 |
Sun |
Mon |
Tue |
Wed |
Thu |
Fri |
Sat |
|
|
|
|
|
|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
|
|
|
|
|
Feb Apr |
|