Should Decorators Preserve the Component Interface?
Virginia Niculescu, Adrian Sterca, Darius Bufnea

TL;DR
This paper introduces variants of the Decorator pattern, such as MixDecorator, D2Decorator, and HybridDecorator, to overcome limitations related to interface constraints and linear composition, enabling more flexible and dynamic object extension.
Contribution
The paper proposes new Decorator variants that allow direct access to added responsibilities and support multiple interfaces, enhancing flexibility over classical Decorator pattern.
Findings
MixDecorator eliminates interface constraints and linear composition issues.
D2Decorator uses double-dispatch for more flexible decoration.
HybridDecorator combines inheritance and composition for dynamic object typing.
Abstract
Decorator design pattern is a well known pattern that allows dynamical attachment of additional functionality to an object. Decorators have been proposed as flexible alternative to subclassing for extending functionality. Still, the Decorator pattern has certain limitations, especially related to the fact that in its classical form it is constrained to a single interface, which is implicitly defined by the type of the concrete components that we intend to decorate. Another problem associated to the Decorator pattern is related to the linear composition of the decorations, which could lead to problems in accessing the newly added responsibilities. In this context, the paper presents variants of the Decorator pattern: MixDecorator and D2Decorator, and a variant specific only to C++ language based on templates - HybridDecorator. MixDecorator could be considered a new enhanced version of…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsLogic, programming, and type systems · Advanced Software Engineering Methodologies · Software Engineering and Design Patterns
