My Blog List
Sponser Link
know more info pls click here
ASP.NET Best pactices in developing asp.net web applications-tech13032012
1. Remove unused private fields and functions.
2. Do not cast unnecessarily. Avoid duplicate casts where possible, since there is a cost associated with them.
3. Properties that return arrays are prone to code inefficiencies. Consider using a collection or making this a method.
4. To test for empty strings, check if String.Length is equal to zero. Constructs such as "".Equals(someString) and String.Empty.Equals(someString) are less efficient than testing the string length. Replace these with checks for someString.Length == 0.
5. Methods in the same type that differ only by return type can be difficult for developers and tools to properly recognize. When extending a type, be sure not to define new methods that differ from base type methods only by type.
6. Use stringbuilder instead of string types for string manipulation.
7. Use String.Format instead of concatenating and appending strings.
8. Use Type.TryParse rather than Convert.ToDestinationType(). For example use int.TryParse() rather than Convert.ToInt32() which might throw an exception.
9. Override Equals() method wherever applicable in your classes.
10. Consider passing base types as parameters - Using base types as parameters to methods improves re-use of these methods if you only use methods & properties from the parameter's base class. E.g. use Stream instead of FileStream as a parameter when only calling Stream.Read(), this makes the method work on all kind of streams instead of just File streams.
2. 1. Do not catch general exception types - You should not catch Exception or SystemException. Catching generic exception types can hide run-time problems from the library user, and can complicate debugging. You should catch only those exceptions that you can handle gracefully.
2. Use properties instead of visible instance fields.
3. Follow the same naming conventions accross the solution.
4. Remove unwanted commented code, Indent code properly.
5. Use curly braces with in an if statement, even if there is a single statement in the if block. This will provide better readability.
6. Make sure to refactor your code to move the duplicated code to common reusable functions.
7. Move one time control settings into the .aspx page rather than having them in the code behind in if(!IsPostback) block.
8. Use inheritance in AuditProvider class which enables code reuse and also reduces the amount of code we have to write and test.
9. Move the reusable javascript functions to an external .js file instead of having them on the page.
10. For controls that are declarativley specified on the page, tie the event handlers to the controls events on the aspx page rather than initializing them in the codebehind. If the controls are built dynamically then we donot have a choice.
11. Make sure to check for nulls when using any type retrieved from a session, querystring or a database to avoid NullReferenceExceptions.
12. Use foreach loop instead of using for loop which may lead to out of boundary run time exceptions.
Subscribe to:
Post Comments (Atom)
Popular Posts
-
<div id="editable" contenteditable="true"> text text text<br> text text text<br> text text...
-
1. Use exception-handling structures to deal with exceptions within the scope of a procedure. This technique is called structured exception ...
-
The Trace object provides the Write and Warn methods to allow you to write messages to a request’s trace information. The two methods are id...
-
There is a little tool called JSPExecutor that allows you to do just that. The developers (Hendrik Schreiber <hs@webapp.de> & Pet...
-
Let me explain the process; 1. First you should go to your adsense account and grab the code for your adsense ads. 2. For this you sh...
-
Few know that those who have web hosting are at the same time endowed with a free VPN (Virtual Private Network, a very safe connection to t...
-
There are a number of ways to get information about a particular Linux command. Chances are you are using bash shell which is currently the...
-
To check if a URL or an email address is valid, the common solution is regular expressions. For instance, to validate an email address in P...
-
we are running a classified site and the latest ads which are coming to the system is indexed in solr write server in every three minutes. T...
-
open source Apache webserver is well-proven, but can still offer an administrator headaches from timeto time when things don't go quite ...
0 comments:
Post a Comment