There are some coding best practice strategies that every one should follow to avoid Best Practice Errors.
1. Use camel cases for all the member variables i.e serverClass (First alphabet of the work should be small and second alphabet should be capital).
2. Use Pascal Case Naming Convention for application Object Tree Elements.
e.g:AddressCountryRegion
First letter of each word should be capital.
3. Parameters Names in Methods should start with _ (underscore).
4. Do not encode the type of a variable in its name eg strName (This is wrong).
5. Do not use multiple comments use only single line comments.No matter how many lines the comment contains.
6. Do not use comment at the end of the line.Unless the comment is very small
e.g: int count; //-1 indicates.
7. Remove Todo comments in advance of a release.
( Todo Comments are basically the comments of code that this code contains bug we will fix it latter or etc.)
8. XML Documentation is basically the Description of the method and its parameters.
We must place XML Documentation above every method.
To create the XML tags place /// above the method or right click
scripts->documentation->HeaderTemplate.
9. Put the method calls inside the conditions so if call are fails than method calls cost will reduce.This is benefit of taking less time consuming.
10. Use field list in select statement.
11. Use Extended Data Types whereever possible.
12. For constant values that are use in multiple places in code you should use #define to define macro that has the constant value.
Example for defining Macros.
#define. MacroName('value')
Example for using Macros.
variable=#Macroname.
13. Use local variables as more as possible.
14. Avoid Global variables as more as possible.
If you want to explore more in Coding Best Practices than here is the link below:
http://msdn.microsoft.com/en-us/library/gg865121.aspx
Thanks
Muhammad Zahid.
1. Use camel cases for all the member variables i.e serverClass (First alphabet of the work should be small and second alphabet should be capital).
2. Use Pascal Case Naming Convention for application Object Tree Elements.
e.g:AddressCountryRegion
First letter of each word should be capital.
3. Parameters Names in Methods should start with _ (underscore).
4. Do not encode the type of a variable in its name eg strName (This is wrong).
5. Do not use multiple comments use only single line comments.No matter how many lines the comment contains.
6. Do not use comment at the end of the line.Unless the comment is very small
e.g: int count; //-1 indicates.
7. Remove Todo comments in advance of a release.
( Todo Comments are basically the comments of code that this code contains bug we will fix it latter or etc.)
8. XML Documentation is basically the Description of the method and its parameters.
We must place XML Documentation above every method.
To create the XML tags place /// above the method or right click
scripts->documentation->HeaderTemplate.
9. Put the method calls inside the conditions so if call are fails than method calls cost will reduce.This is benefit of taking less time consuming.
10. Use field list in select statement.
11. Use Extended Data Types whereever possible.
12. For constant values that are use in multiple places in code you should use #define to define macro that has the constant value.
Example for defining Macros.
#define. MacroName('value')
Example for using Macros.
variable=#Macroname.
13. Use local variables as more as possible.
14. Avoid Global variables as more as possible.
If you want to explore more in Coding Best Practices than here is the link below:
http://msdn.microsoft.com/en-us/library/gg865121.aspx
Thanks
Muhammad Zahid.
No comments:
Post a Comment