vendredi 18 mai 2018

Design pattern to evaluate different type set of rules

I have set of different type of rules to be evaluated. each rule has different statistics,

  • each rule is in different database tables.
  • evaluating logic is different for each rule type
  • different messages have to be generated based on the evaluation.
  • status of evaluation should be saved to each rule's database table.

I'm planning to implement it base on Builder pattern, Like,

foreach(Rule rule in Rules){
  var result = rule.evaluate();
  var message = rule.getMessage(result);
  rule.saveMassage(message);
  rule.updateDB(result);
}

Is my approach OK? or a better way of doing it?

Aucun commentaire:

Enregistrer un commentaire