ASP.NET Coding Standards and Guidelines


Hello everybody,

As I have already discussed about coding standards on ASP.net, here are some more..

1.Always using form name with Prefix frm along with page name and user control name user control names with “uc” as prefix

2. The rest of the user control name should be in Pascal Casing (Ex. ucMyUserControl)

3. Do not use session variables throughout the code. Use session variables only within the classes and expose methods to access the value stored in the session variables.

4. Do not store large objects in session, it may consume lot of server memory depending on the number of users.

5. Do not put order by or where or top clause in the query unless required.

6. Do not encapsulate readonly database operations in transactions.

7. Use a stored procedure with output parameters instead of single record SELECT statements when retrieving one row of data.

8. Stored procedure execution is fast when we pass parameters by position (the order in which the parameters are declared in the stored procedure) rather then by name.

9. Never declare an empty catch block.

10. Error Message should be user friendly, simple and understandable.

11. All source code must include the following comments at the very top as a #region:

/********************************************************
*Author:
*Date:
*Description:
********************************************************/

Comments