Specification Based Factory
Cool stuff today.
Simon and James came up with a new use for the Specification pattern. They combined it with the Factory pattern.
Basically, we need to find a class under some pretty heavy conditions (OK maybe we need a strategy pattern). They look up the class in a Map, indexed by a Specification object. They iterate over the map evaluating the specification, when one return trues they poof up a new instance of the class contained in the value.
Nice explicit code, with each rule contained in its own specification object.
I love simple stuff.
0 Comments:
Post a Comment
<< Home