A simple rules engine
I'm extracting data from some OCR'd letters and, in order to determine which type of letter I'm parsing, I'm using a method similar to this: public Letter Parse(string text) { Letter result; if (text.IndexOf("...", StringComparison.OrdinalIgnoreCase) >= 0) letter = new LetterA(); else letter = new LetterB(); //... additional processing return letter; } If the letter contains a specific text, I know it's of one type; otherwise I'll default to the other type. Unfortunately that's going to get really complicated, really fast once I start adding new letter types. I read somewhere that "you should move logic out of the code and into the data when possible"; it made sense and I never had a reason to regret it. So, let me try to do that here. First I'll add a "rules list" class that will allow me to store the ...