Design a system enabling to display visual objects on a screen. A visual object can be composed with one or more texts or images. If needed, the system must allow to add to this object a vertical scrollbar, an horizontal scrollbar, an edge and a menu (these additions may be cumulated).
Optimal solution :
Static diagram :
In this solution, if we add a new decoration, there is no code modification. Moreover, the decorators are able to decorate themselves.
Alternative solution :
Static diagram :
This solution presents problems on decoupling and extensibility.