I have a few different types of validator classes that i am using at the moment all implementing a validator interface. Occasionally i require combinations of them but usually i need them individually. Does this sound like a good situation to use the composite pattern?
+2
A:
Could be, based on the minimal information you provide.
You could implement a Validator which contains a collection of other validators, and uses all of the child validators to validate the given data.
As an extension/alternative, you could also implement logical operations via this pattern, e.g. Validators which AND / OR / XOR etc. the result of two (or more) child validators.
Péter Török
2010-09-19 19:29:42