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.

Get Professional PHP Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.