4.2. UML
This Unified Modified Language (UML) diagram details a class design using the Builder Design Pattern (see Figure 4-1).
Figure 4-1. Figure 4-1
Note the following concerning this figure:
The MyObject class has two methods to completely finish the construction of the object. Both complexFunctionA() and complexFunctionB() need to be executed in order to have a complete MyObject object.
The MyObjectBuilder class contains a method called createInstanceOfMyObject(). This class is responsible for creating a simple instance of the MyObject class. Note how no configuration options have been used to further construct it. It also stores the instance privately in that instance of the MyObjectBuilder class.
The buildMyObject() method takes a parameter of configurationOptions. This is used to call both complexFunctionA() and complexFunctionB() of the MyObject object stored in the MyObjectBuilder object.
The getBuiltMyObject() method returns the private instance of MyObject inside the MyObjectBuilder object, completed and built properly.
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