We don't have code reviews, but sometimes I have to tell the team quite obvious coding recommendations.
There are a few examples:
1. We should do the check if array element is available before access it:
E.g. BAD:
string departureCity = Flight[0].StartPoint;
GOOD: if (Flight.Rows.Count <= 0)
{
WarningMessageEvent.Raise("Flight.Rows.Count <= 0");
return;
}
string departureCity = Flight[0].StartPoint;
2. Keep separate functionality in small functions, rather than add morre code to existing functions, that makes them too big.
It is easier to read, test, maintain and investigate errors.
You can use VS Refactor –Extract Method to make functions smaller.
Also highly recommend to install RefactorAsp from http://www.devexpress.com/Products/Visual_Studio_Add-in/RefactorASP/index.xml.
See "Common Refactors" section here about
Extract method
Replace Method with Method Object
Decompose Conditional
List of Refactors can be viewed here(or original here).
3. Do not "eat" exceptions
Even if you don’t want to report errors in production, Debug.Assert them in development environment to understand, why they happen and avoid them.
E.g. BAD:
catch
{
//we ignore any errors
}
GOOD:
catch(Exception exc)
{
//we ignore any errors in production
Debug.Assert(false, "Investigate why " + exc.ToString());