I have to read business rules stored in XML file (I am using VC++/MFC/MSXML). XML consists of rules. Each rule has a set of conditions and actions. What would be an elegant OOP design for such system? What design patterns would you use if you where a designer of such system?
update:
Rules are put in sequence and executed one buy one if all conditions of rule are met.
example of xml:
<rules> <!-- rule no. 1 --> <rule name='rule no. 1'> <conditions> <condition name='condition no. 1' type='ATTR_EMPTY'> <parameters> <parameter name='attribute_name'>ttt</parameter> <parameter name='workflow_id'>3</parameter> <parameter name='workflow_state_id'>5</parameter> </parameters> </condition> <condition name='condition no. 2' type='ATTR_EMPTY'> <parameters> <parameter name='attribute_name'>ttt</parameter> <parameter name='enviroment_id'>3</parameter> </parameters> </condition> </conditions> <actions> <action name='action no. 1' type='ATTR_CLEAR'> <parameters> <parameter name='attribute_name'>ttt</parameter> </parameters> </action> </actions> </rule> </rules>
Difficult to tell from such a brief description, but I would make each rule an object which manages its own conditions and actions. The rules would be created by a factory from the XML and stored in some sort of dictionary.