TechShri from Shriniwas Wani

Custom Search

23 January, 2008

C# .Net Code Review

Reduce round trips.
Use caching. Cache the right data.

Avoid unnecessary exceptions.
Explicitly call Close or Dispose on resources you open. Obtain resources late and release them early.
Use Page.IsPostBack to minimize redundant processing.
Ensure debug is set to false.

Optimize expensive loops.
Consider using Server.Transfer instead of Response.Redirect.
Use client-side validation.

Use server controls where appropriate.
Identify the use of view state in your server controls.
Separate dynamic data from static data in your pages.
Understand serialization costs lot.

Use static properties instead of the Application object to store application state.
Disable session state if you do not use it.
Use the ReadOnly attribute when you can.

Disable view state if you do not need it.
Minimize the number of objects you store in view state.
Determine the size of your view state.

Use HtmlTextWriter when building custom controls.
Use StringBuilder for temporary buffers.
Use Response.Write for formatting output.

Use try/finally on disposable resources. Write code that avoids exceptions.
Set timeouts aggressively.
Implement a Global.asax error handler.

Avoid storing COM objects in session state or application state.

Use a DataReader for fast and efficient data binding.

Turn off authentication for anonymous access.
Disable tracing and debugging.
Avoid caching sensitive data.

0 Comments:

Post a Comment

<< Home