I'm facing a problem with a customer of mine that I need to somehow adddress better than I have done so far.
At the end of the program execution, a csv file is generated with a few thousands records for later import on a central Oracle database localized in Germany. The generation of this csv file is not straightforward, however. A few business rules will alter the data or how it is generated. Three examples (there's more than that):
- The fields in the csv file may obey a different order than the one on the local database.
- Some date fields use MM/DD/YYYY, while others use DD/MM/YYYY
- Phone numbers must be prefixed with '+' followed by country code.
Since the local database, from where the data is collected for the csv generation, respects the local business rules, it's not desirable to reflect these business rules in the local database. Instead, it's the csv export functions in my program that should do the mapping. And so I have done so far.
But these business rules are always changing, new ones being introduced, or old ones removed... with the chance of later being reintroduced. I find myself altering the code in ways I didn't want to. I need some method to this madness. What I would like to know is how would you tackle such a problem?
I'm thinking in compartmentalize the business rules into some form of structure with pointers to functions, so that I can easily locate and change nodes, add new nodes, deactivate others (keeping them for reuse later, if I must) and create a FSM to conduct the workflow between these nodes.
Have you ever encountered this problem where the business rules of your application are frequently mutable? What do you suggest I do?