Chapter 29. Visitor
The ordinary way to extend a class hierarchy's behavior is to add methods that provide the behavior you need. It may happen, though, that the behavior you need is not consistent with the thrust of the existing object model. In other cases, the developer of a hierarchy may have little information about the behaviors that later developers will need.
If the developers who control the hierarchy code can't or won't change quickly enough to meet your needs, it may be impossible to extend the hierarchy's behavior without modifying the hierarchy's classes. But VISITOR lets a hierarchy developer build in support for the prospect that another developer may want to extend the behavior of the hierarchy. The intent of VISITOR is to let ...
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