I have been given a file with several records. I have also been given business rules that determine how to process those records and produce an output file. The business rules are relatively simple:
- If record is of type A, use methodology A.
- If record is of type B, use methodology B.
However my client emailed me with a problem: There is one "special" record in the file. It's a type A record, but it needs to be processed with methodology B.
How does one deal with these exceptions to business rules? Some options I have thought of so far:
- Hard-code the exception into the software:
if record.id == "some_id" && record.value == 123.45 then methodology B. - Manipulate the file by hand, run the program, and then correct the output by hand.
My coworker is astonished that I would even consider option 1. It's messy, and next year (when I have to run this process again) the file could be different. It will turn out to a nice hidden "gotcha" that could cause problems long after I forgot about the exception.
However option 1 is easier than option 2, and if the exception to the rule stays the same for next year, I won't have to even think about it. It's already been handled. Besides, it's easy to change if I need to change it later.
How do I deal with random exceptions to business rules?
EDIT:
This is very targeted software - written to specifically do one job for one client.


catch'em! Sorry, couldn't resist. ;) – deceze May 25 '12 at 5:29