Terminology and Definitions for Naming Conventions:
Camel Case (camelCase): The first letter of the word is lower case and then each first letter of the part of the word is upper case;
Pascal Case (PascalCase): The first letter of the word is upper case and then each first letter of the part of the word is upper case;
Underscode Prefix (_underscore): The word begins with underscore char and for the rest of the word use camelCase rule;
General Rules
1. Use Pascal Case for Class names:
Ex: public class HelloWorld { ... };
2. Use Pascal Case for Method names:
Ex: public void SayHello(string name) { ... };
3. Use Camel Case for variables and method parameters:
Ex: int totalCount = 0;
void SayHello(string name)
{
string fullMessage = "Hello " + name;
//...
}
4. Avoid all upper case or all lower case names;
5. Do not use Hungarian notation:
Ex: string m_sName; (the prefix m_ means that is a member variable and s means that is a string data type);
6. Avoid abbreviations longer than 5 characters;
7. Avoid using abbreviations unless the full name is excessive:
Ex: Good: string address;
Not good: string addr;
8. Use meaningfull, descriptive words for naming variables;
9. Try to prefix Boolean variables with “Can”, “Is” or “Has”;
10. Do not use Underscore Prefix for local variables names;
11. All member variables must use Underscore Prefix so that they can be identified from other local variables names;
12. Avoid naming conflicts with existing .NET Framework namespaces or types;
13. Do not include the parent class name within a property name:
Ex: Good: Customer.Name;
Not good: Customer.CustomerName;
14. When defining a root namespace, use a Product, a Company or a Developer name as the root:
Ex: NorthwindApplication.Utilities;
15. Use Pascal Case for file names;
16. Method name should tell you what it does;
17. A method should do only “one job”. Do not combine multiple jobs in one method even if those jobs have very few lines of code.
Ex:
protected void SaveCustomerName(string customerName)
{
//code here...
}
Naming Conventions for ASP.NET Controls
In general, naming ASP.NET controls is made using Camel Case naming convention, where the prefix of the name is the abbreviation of the control type name.
Camel Case (camelCase): The first letter of the word is lower case and then each first letter of the part of the word is upper case;
Pascal Case (PascalCase): The first letter of the word is upper case and then each first letter of the part of the word is upper case;
Underscode Prefix (_underscore): The word begins with underscore char and for the rest of the word use camelCase rule;
General Rules
1. Use Pascal Case for Class names:
Ex: public class HelloWorld { ... };
2. Use Pascal Case for Method names:
Ex: public void SayHello(string name) { ... };
3. Use Camel Case for variables and method parameters:
Ex: int totalCount = 0;
void SayHello(string name)
{
string fullMessage = "Hello " + name;
//...
}
4. Avoid all upper case or all lower case names;
5. Do not use Hungarian notation:
Ex: string m_sName; (the prefix m_ means that is a member variable and s means that is a string data type);
6. Avoid abbreviations longer than 5 characters;
7. Avoid using abbreviations unless the full name is excessive:
Ex: Good: string address;
Not good: string addr;
8. Use meaningfull, descriptive words for naming variables;
9. Try to prefix Boolean variables with “Can”, “Is” or “Has”;
10. Do not use Underscore Prefix for local variables names;
11. All member variables must use Underscore Prefix so that they can be identified from other local variables names;
12. Avoid naming conflicts with existing .NET Framework namespaces or types;
13. Do not include the parent class name within a property name:
Ex: Good: Customer.Name;
Not good: Customer.CustomerName;
14. When defining a root namespace, use a Product, a Company or a Developer name as the root:
Ex: NorthwindApplication.Utilities;
15. Use Pascal Case for file names;
16. Method name should tell you what it does;
17. A method should do only “one job”. Do not combine multiple jobs in one method even if those jobs have very few lines of code.
Ex:
protected void SaveCustomerName(string customerName)
{
//code here...
}
Naming Conventions for ASP.NET Controls
In general, naming ASP.NET controls is made using Camel Case naming convention, where the prefix of the name is the abbreviation of the control type name.
Abbreviation | ASP.NET Control |
STANDARD CONTROLS | |
btn | Button |
cb | CheckBox |
cbl | CheckBoxList |
ddl | DropDownList |
fu | FileUpload |
hdn | HiddenField |
lnk | Hyperlink |
img | Image |
ibtn(btn) | ImageButton |
lbl | Label |
lbtn(btn) | LinkButton |
lb | ListBox |
lit | Literal |
mv | MultiView |
pnl | Panel |
ph | PlaceHolder |
rb | RadioButton |
rbl | RadioButtonList |
tbl | Table |
txt | TextBox |
v | View |
DATA CONTROLS | |
dtl | DataList |
dp | DataPager |
dtv | DetailsView |
ets | EntityDataSource |
fv | FormView |
gv | GridView |
lds | LinqDataSource |
lv | ListView |
ods | ObjectDataSource |
qe | QueryExtender |
rpt | Repeater |
smd | SiteMapDataSource |
sds | SqlDataSource |
xds | XmlDataSource |
VALIDATION CONTROLS | |
cpv | CompareValidator |
ctv | CustomValidator |
rv | RangeValidator |
rev | RegularExpressionValidator |
rfv | RequiredFieldValidator |
vs | ValidationSummary |
No comments:
Post a Comment