Following 20 points which are discussed below are not an expert advice, however,it is based on my knowledge & experience.
It is nice to follow these guideline for better coding practice.
General Guidelines:
1)Write comment for all methods.
2)Please don’t write many lines of code in a single method instead make separate private methods and write into them.
3)When you are writing many if endif statement, write comment after each if and endif statement.
4)When you are writing many if endif statement, write comment after each if and endif statement.
5)do not hard code the integer value in the code file, Write into a configuration file or store into database otherwise its very tough to change later on, if needed.
6)store long messages that need to show to the user in case of error or any condition failure into configuration file.
7)Please check query string value for correct format before storing into variables.
8)When you are instantiating an object and calling its methods, please write some comments about the object & its methods. Give some meaningful name to the object or variables.
9)Generally variable declaration should not be kept inside the try block. Put variables declaration out of try block. Try block is used to execute any method that can throw error.
10)In Page_Load event, please use IsPostBack condition, wherever possible.
11)Please unit test the code at least twice before sending for review or sending to the client.
12)String properties of a control or string variables should not be convert into string.
13)Use StringBuilder instead of string concatenation.
14)Instead of directly assigning the value of lblLinks.Text, Concatenate with StrinBuilder and assign the value of the lblLinks.Text at last.
15)DataSet, DataTable should be disposed in finally block.
16)When you are instantiating any object and it has no Dipose method, the ideal way is to nullify the object (in finally block), this indicate the Garbage Collector (GC) that the object is not going to use so its ready to be disposed. However, there is another thought also. As soon as the scope definition of the object ends, the object is ready to be disposed so GC will automatically takes care of it.
17)If there is no proper use of Catch block, do not use catch block.
18)If try is used and exception is caught, it must be handled otherwise error should be thrown.
19)Avoid variable declaration inside the loop.
20)Don’t instantiate any object that you are not going to use.
Any Additional tips and comments are really appreciated
It is nice to follow these guideline for better coding practice.
General Guidelines:
1)Write comment for all methods.
2)Please don’t write many lines of code in a single method instead make separate private methods and write into them.
3)When you are writing many if endif statement, write comment after each if and endif statement.
4)When you are writing many if endif statement, write comment after each if and endif statement.
5)do not hard code the integer value in the code file, Write into a configuration file or store into database otherwise its very tough to change later on, if needed.
6)store long messages that need to show to the user in case of error or any condition failure into configuration file.
7)Please check query string value for correct format before storing into variables.
8)When you are instantiating an object and calling its methods, please write some comments about the object & its methods. Give some meaningful name to the object or variables.
9)Generally variable declaration should not be kept inside the try block. Put variables declaration out of try block. Try block is used to execute any method that can throw error.
10)In Page_Load event, please use IsPostBack condition, wherever possible.
11)Please unit test the code at least twice before sending for review or sending to the client.
12)String properties of a control or string variables should not be convert into string.
13)Use StringBuilder instead of string concatenation.
14)Instead of directly assigning the value of lblLinks.Text, Concatenate with StrinBuilder and assign the value of the lblLinks.Text at last.
15)DataSet, DataTable should be disposed in finally block.
16)When you are instantiating any object and it has no Dipose method, the ideal way is to nullify the object (in finally block), this indicate the Garbage Collector (GC) that the object is not going to use so its ready to be disposed. However, there is another thought also. As soon as the scope definition of the object ends, the object is ready to be disposed so GC will automatically takes care of it.
17)If there is no proper use of Catch block, do not use catch block.
18)If try is used and exception is caught, it must be handled otherwise error should be thrown.
19)Avoid variable declaration inside the loop.
20)Don’t instantiate any object that you are not going to use.
Any Additional tips and comments are really appreciated
No comments:
Post a Comment