Fail Fast principle
Recently I received a NullReference-Exception when I called another method from a foreign component. Fortunately I had the source code of this component and I found the following code: [code language=”csharp”] public class AgeValidator { public Dictionary Config { get; set; } public bool Validate(int nAge) { int nMinAge = FindValue(“MinAge”); return nAge > nMinAge; } private int FindValue(string strParameter) { int nValue = -1; if(this.Config.ContainsKey(strParameter)) nValue = this.Config[strParameter]; return nValue; } } [/code] There are several problems with this…