mercredi 27 avril 2016

Do you know the good design pattern for this algorithm?

Here is my system : I have x Mailer objects, each of them are differents instances of the same class (but with different properties)

I have to structure an algorithm to choose 1 Mailer between them :

  • I have to evaluate all of the Mailers (is_active, is_active_for_this_period, ...), if the Mailer can be used, put it in a list of "valid" Mailer objects
  • Choose randomly between the valid Mailers
  • Return the object (to use it after)

Do youknow a design pattern to do that ? I don't find a good pattern to "choose" an object, given a list of them

Thank you Florian

Aucun commentaire:

Enregistrer un commentaire