Click here to Skip to main content
Click here to Skip to main content

Easy Naming Practices for .NET Coding

By , 18 Mar 2006
Rate this:
Please Sign up or sign in to vote.

Introduction

While writing codes for .NET applications, if you and your team members have some common naming practices, it becomes very useful especially when you're reading your existing codes and modifying your codes in Visual Studio .NET IDE. For naming conventions, I went to the MSDN site, but got so many links which made me a bit frustrated to read all the stuffs by spending couple of hours. However I have used my Microsoft Word application and very quickly written some naming conventions, which can be read and can be used very quickly. My team has found it fruitful; I believe you can find it useful as well.

UI Naming Prefix

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 Calendar cnd
18 AdRotator art
19 Table tbl
20 RequiredFieldValidator rfv
21 CompareValidator cmv
22 RangeValidator rgv
23 RegularExpressionValidator rev
24 CustomValidator csv
25 Validation Summary vsm

Casing of Codes

Name Space Name Case NameSpaceName
Class Naming Case ClassName
Method Naming Case MethodName
Property Naming Case PropertyName
Enum Case EnumName
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 like this.
Private Data _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_ prefix causes performance 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 the 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 is a separate class for each entity, we can exclude the entity name from the method names.

Property

  • FieldName

Property Constants

  • _FieldName

Method Parameter that is Assigned to Property

  • fieldName

Conclusion

Any advice or correction for this article will be highly appreciated.

History

  • 18th March, 2006: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Mohammad Ashraful Alam
Chief Technology Officer
Bangladesh Bangladesh
Mohammad Ashraful Alam is a Software Engineer, who is dedicated to Microsoft .NET based development. This Bangladeshi national is involved with project management and development of several US based software projects from his country. Already he has managed and developed 15 software projects, which are being used by several users of different countries, such as USA, Canada, Australia, and Bangladesh. While developing and managing a team, he contains and maintains a set of well defined engineering practices developed by him and other online developer community. Beside software development, he has also written several technical articles and research papers published by IEEE Computer Society and many other worlds recognized publishers.
 
Before becoming engaged with software development, he was involved with Bengali literature and several Bengali news papers as freelance journalist and published around 150 articles, essays and short stories.
 
Due to his willingness to give effort to improve and share better software development practices, Ashraf has awarded as “Most Valuable Professional” (MVP) in ASP.NET category by Microsoft for multiple times, since 2007.
 
When not engaged with technical stuffs, he likes to pass time with his friends, and family members, listens music or watches TV.
 
Check his portfolio at: http://www.ashraful.net/.
 
Check his blog: http://blog.ashraful.net/.
 
Catch him thru mail: admin [attt] ashraful [dotttt] net (anti-spam text).

Comments and Discussions

 
GeneralThis is an outdated way of thinking [modified] Pinmembersngbrdb5-Jul-06 3:29 
GeneralDisagree with database conventions Pinmemberhexy19-Mar-06 10:34 
GeneralRe: Disagree with database conventions Pinmemberjoycsc19-Mar-06 19:02 
GeneralRe: Disagree with database conventions Pinmemberhexy19-Mar-06 22:19 
GeneralNaming Practices. PinmemberGeorge L. Jackson19-Mar-06 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 18 Mar 2006
Article Copyright 2006 by Mohammad Ashraful Alam
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid