Reducing code noise when checking for null parameters
The problem with writing defensive fail early code, it doesn’t take long before methods are 70% argument checking, 30% logic: [code language=”csharp”] public void Method(object arg1, object arg2) { if (arg1 == null) { throw new ArgumentNullException("arg1"); } if (arg2 == null) { throw new ArgumentNullException("arg2");</div> } … … … } [/code] Code contracts can…