Chapter 19. Visitor Pattern

Society keeps driving for more features and more value with everything they obtain. The days of being happy with a simple set of features or the "classic" item is nearly gone. Programming and applications are not immune to this trend. Companies are finding that the demand for new features is so intense that extra programmers are needed. They have independent consultants come visit the main office and request to have the application "made better." Each consultant is basically told the same thing — create a new feature — and they provide the same product: the finished feature. However, internally, they all take different routes to accomplish this goal. In this same way, some sets of objects are designed to visit the application logic and "make it better" in their own unique way. This is where the Visitor Design Pattern becomes useful.

Name: Visitor

The Visitor Design Pattern constructs distinct objects containing an algorithm that, when consumed by a parent object in a standard way, apply that algorithm to the parent object.

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.