I had some engaging conversation with my co-worker and we've discussed the "proper way" of Decorator Pattern usage. Unfortunately I couldn't find any confirmation of my assumptions and it's the reason of how my question have begotten.
- If we have
DecoratorImplwhich both implements that interface, it's a decorator pattern?
- But if our
HandlerInterfacecontains many methods, and we want to decorate only some methods, we could use also
HandlerInterfacecontract and some of its methods by default?
- But what if we have only one implementation of
HandlerInterface? May it become redundant in some use cases? Which could mean, we don't need an interface only for this and we could just replace usages of
- And then our
AbstractDecoratorwill not implement
HandlerImplinstead. And if we would've done this. Why couldn't we just remove
HandlerImpldirectly in our
DecoratorImplas a contract? Maybe it's a bit far from the standard design, but as I understand, It's still a decorator pattern but after some modifications.
So, Is it a good way of thinking? Or maybe I'm missing something? Let me know. Thanks in advance.