In the decorator pattern, the decorator class inherits from the component class and has an aggregation relationship with it. Well, the aggregation relationship is logical, but why should we inherit from the component? This pattern is supposed to decorate the component, so why does it need to inherit from it? If we have a component object in the decorator, we can add new functionalities to our class at runtime as we want, but I don't understand the inheritance.
Aucun commentaire:
Enregistrer un commentaire