What is a Decorator pattern?
-
decouple an abstraction from its implementation so that the two can vary independently
-
One class takes in another class, both of which extend the same abstract class, and adds functionality.
-
Assembles group of objects with same signature
-
One class controls the creation of and access to objects in another class.
The Decorator pattern attaches additional responsibilities to an object dynamically. It wraps a component (both implement the same interface) to add behavior without modifying the original class. Option A describes Bridge pattern (decoupling abstraction from implementation), Option C describes Composite pattern (tree structures of objects), and Option D describes Facade pattern (simplified interface to a complex subsystem).