Introduction
While writing codes for .NET applications, if you and your team members contain some common naming practices, it becomes very useful, especially when you're reading your existing codes and modify your codes in VS.NET IDE. For naming conventions, I went to MSDN site, but got so much links, which made to a bit frustrated to read all the stuffs by spending couple of hours. However I have used my MS Word application and very quickly wrote some naming conventions, which can be read and can be used very quickly. My team has found it fruitful; however, I believe you can find it useful as well as.
UI Naming Pefix
1. Buttons --btn
2. DropDownList --ddl
3. LinkButton --lnb
4. Label -- lbl
5. Repeater --rpr
6. DataGrid --dgd
7. CheckBox --chk
8. RadioButton --rdo
9. DataList --dls
10. Image -- img
11. TextBox -- txt
12. ImageButton -- imb
13. HyperLink --hln
14. ListBox -- lst
15. Panel -- pnl
16. PlaceHolder -- phd
17. Calender --cnd
18. AdRotator --art
19. Table -- tbl
20. RequiredFieldValidator --rfv
21. CompareValidator --cmv
22. RangeValidator -- rgv
23. RegularExpressionValidator -- rev
24. CustomValidator -- csv
25. Validation Summery --vsm
Casing of Codes
Name Space Name Case: NameSpaceName
Class Naming Case: ClassName
Method Naming Case: MethodName
Property Naming Case: PropertyName
Enum Case: EnamName
Enum Members: EnumMemberName
Constant Name Case: ConstantName
Local Variable Naming Case: variableName
param Variable Naming Case: paramName
Region Names: Region name will be sentence case like this.
Code Comments: Comments will be in general case likethis.
PrivateData: _privateDataName
Database
Tables, Relations
Table Name Prefix: tbl
Table Name Case: tblTableName
Primary Key Name: PK_tblNameID
Foreign Key Name: FK_'ForeignKeytblName'ID
Stored Procedure
Stored Procedure Prefix:
spr_StoredProcedureName
NOTE: Starting by 'sp_' prefixcauses preformance overhead.
CRUD (Create-Read-Update-Delete) Stored Procedures Names:
INSERT: spr_tblTableName_Insert
UPDATE: spr_tblTableName_Update
DELETE: spr_tblTableName_Delete
READ BY PRIMARY KEY:spr_tblTableName_GetByPrimaryKey
READ BY FOREIGN KEY:spr_tblTableName_GetBy'KeyName'
READ ALL: spr_tblTableName_GetAll
NOTE 1: This standard groups the stored procedures by table wise cluster, which facilitates changes on a table schema modification in stored procedure layer.
NOTE 2: For multiple table CRUD operation use the following example: INSERT: spr_tblTableName[1_tblTableName2_...tblTableNameN ]_Insert
Other Database Objects
Function Name Prefix: fnc_
Trigger Name Prefix: trg_
Cursor Name Prefix: crs_
View Name Prefix: viw_
CRUD [Create-Read-Update-Delete] Methods of Data Access Class
Methods:
CreateEntityName
UpdateEntityName
DeleteEntity
GetAllEntityName
GetEntityNameById
GetEntityNameBy'KeyName'
NOTE: For DAL/BLL when there isseparate class for each entity, we can exclude the entity name from the methodnames.
Property:
FieldName
Property constants:
_FieldName
Mothod parameter that isassigned to property:
fieldName
Conclusion:
Any advice or correction for this article will be highly appreciated.