We are lucky to have a client that is tech savvy. And most of the times our code is being reviewed by their tech architects. Most of the times we get reviewed our code on a frequent time intervals. On one side it is good, on the other side it leaves our developers with some morel loss. Adding to the fuel, is me. I insist my developers to follow certain standards within their code. It is time to post the general points that I emphasize.
1) Use long names for variables
2) Initialize variables at the time of declaration
3) Use .Equals instead of ==
4) Use territory operator ?:
5) Use ?? when expecting the null reference
6) Use .Length() comparison to validate string with values
7) Use StringBulder instead of strings concatenation
8) Use StringBuilder replace instead of string (Ref : http://dotnetperls.com/replace-string-use)
9) Use single line assignments for common values
10) Avoid try catch as much possible
11) Organize Usings and remove & sort the references
12) Use white spaces within every expression
13) Separate user methods from system generated methods. Use of Region
14) Give Author details on every page
15) Maintain the history of modification
16) Write the code in as small reusable methods as possible.
17) Never assing objects to null when they are within the loop
18) If you can use the GC.KeepAlive, make the best use of it
19) Try to separate the Finalze method into a different class and instantiate in the caller class that implements the IDisposable interface
20) Make use of WeakReference to avoid the multiple connections / reads from static content
21) Use int.TryParse, instead of Convert.ToInt or int.Parse
22) Never Ever Trust the User Input, do use Encoding where ever necessary
There are much more, this list would never end. But these are general guidelines that are in my mind at any given time. And different approaches can be identified depending on the situation that the code is in.