DO:
Foo.cs:
public class Foo { … }
DON'T:
Foo.cs:
public class Foo { … }
public class Bar { … } // this should be in Bar.cs
DO:
return debitAmounts.Sum();
DON'T:
var sum = 0;
foreach (var debitAmount in debitAmounts)
{
sum += debitAmount;
}
return sum;
Readability: Prefer implicitly typed local variables
DO:
var termMonths = loan.TermInMonths;
var loanAmount = loan.Amount;
var interestRate = loan.interestRate;
var inServiceDate = vehicle.InServiceDate;
var vin = vehicle.vin;
DON'T:
int termMonths = loan.TermInMonths;
double loanAmount = loan.Amount;
double interestRate = loan.interestRate;
DateTime inServiceDate = vehicle.InServiceDate;
string vin = vehicle.vin;
Readability: Prefer foreach (...)
statement over ForEach()
extension method to make looping constructs easier to spot.
Readability: Use simplified type names unless fully qualified type names are necessary to avoid type collision.
DO:
using Foo.Bar.Baz;
public void DoSomething(Qux qux) { … }
DON'T:
public void DoSomething(Foo.Bar.Baz.Qux qux) { … }