Need flexible rules pattern

Need flexible rules pattern

Old forum URL: forums.lhotka.net/forums/t/5293.aspx


bgilbert posted on Monday, August 25, 2008

I have two tables with associated classes that represent defect codes and disposition codes. Each table has a boolean column called RequiresApproval. If this is set to true, the user needs a supervisor's approval to use this defect or disposition code.

My client now wants a rule that allows a RequiresApproval flag on combinations of Defect Codes and Disposition Codes. So, defect code A might not require approval and disposition code B might not, but the combination would. Our first thought was to have an association table that stores the two codes' keys and a boolean field. We would then write some code to evaluate this combination, perhaps in a DefectDisposition object. This brought up a broader question. What if the client asks for the rules to get more complex, involving other tables or columns? Do we continue to add association tables, classes, etc?

In light of this, we've been discussing an Approval class that could somehow manage any combinations of rules from any entities. This, however, still doesn't answer the question of how to store the rules, how to allow the client to maintain the rules, and how to evaluate them.

Any help/ideas would be appreciated.

Barry

Copyright (c) Marimer LLC