How would I implent the decorator pattern without the base class / concrete component? Basically I only want the decorator part of the decoration pattern, in order to build a nested structure to extend my functionality with each nesting. Problem is, what do I pass to the innermost object of the nested structure (where you normally pass the base class)? A null object and specifically check for it?
E.g.
ICondition: boolean isFulfilled()
ConditionA implements ICondition
ConditionB implements ICondition
ICondition nestedConditions = new ConditionB(new ConditionA))
public boolean isFulfilled() {
boolean isFulfilled = //algo for this condition
return condition.isFullfilled && isFulfilled; //check if the condition of the injected and this condition is fulfilled
}
Aucun commentaire:
Enregistrer un commentaire