9.2. UML
This Unified Modified Language (UML) diagram details a class design using the Factory Design Pattern (see Figure 9-1).
Figure 9-1. Figure 9-1
Note the following about this figure:
Two base classes exist: MyObjectTypeA and MyObjectTypeB. Both have a public method called doSomething(), which executes the logic of that object in its own unique way. Their public interfaces and return types are identical.
The MyObjectFactory class exists to create an instance of either one of these base classes and return it to the code stream. MyObjectFactory has one public method, named createObject(). This accepts a parameter called type. This helps determine which of the two base classes should be created. The createObject() method then returns an instance of the requested type class.
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