vendredi 10 avril 2015

OO Software desing handling constraints - which design pattern to use?

i have a question regarding software design. I think what im looking for is a well known problem and therefore there has to be a design pattern or a mix of patterns to solve it. But i cant figure it out.


Ok, heres the question. For example lets say that i have the following classes and properties:


CTask



  • Name

  • Duration

  • TaskArea


CTaskArea



  • Name


CPerson



  • Name

  • Abilities


CAbility



  • Name


CTool



  • Name

  • CleaningTime


CConstraint



  • Name

  • Constraint


CTask, CPerson, CTool could have constraints e.g. Task A could only be done by persons with ability X, or person A could not do tasks of TaskArea X and so on. For example when i create a new CTask, CPerson or CTool i could imagine a constraint config dialog with dropdwons like:


Class | Operator | Class | Property | Value


CPerson | NOT | CTool | Name | Hammer


What is the best way to design this to have the opportunity to dynamically configure constraints for all the classes that could have constraints? I started looking at the observer pattern to have all the coinstraint capable classes registered, but i think there are better ways. What do you think?


Thanks in advance!


Tim


Aucun commentaire:

Enregistrer un commentaire