17.2. UML

This Unified Modified Language (UML) diagram (see Figure 17-1) and following list detail a class design using the Strategy Design Pattern.

  • MyObject contains a public property called name. This represents the property of MyObject that normally accepts modification. The public method setName() receives one parameter, called name. This is assigned to the MyObject name property.

  • MyObjectStrategy is the self-contained algorithm object. It has one public method, named change(). This accepts a parameter of MyObject. change() and executes that specific logic against the MyObject by modifying its public name variable.

Figure 17-1. Figure 17-1

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.