6.2. UML
This Unified Modified Language (UML) diagram details a class design using the Decorator Design Pattern (see Figure 6-1).
Figure 6-1. Figure 6-1
Note the following about this figure:
The MyObject is the base class with the existing functionality. It contains a public array named items and a public method named showItemsFormatted().
showItemsFormatted() is responsible for taking the items array, formatting them using predefined functionality, and presenting output.
The MyObjectDecorator class contains a private instance of MyObject and two public methods, named MyObjectDecorator() and decorateItems().
The MyObjectDecorator() method represents the constructor. It takes a parameter of type MyObject and stores it internally.
The decorateItems() method modifies the items array of the MyObject instance.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access