Chapter 15. Visitor
Imagine you have some plumbing problems in your house but you don't know how to fix them. Even though you are the owner of the house, that doesn't mean you know all the ins and outs of it. Therefore, the most efficient way to solve this problem is to call in an expert to get it fixed as soon as possible.
In software design, a class can become extremely complex if the architect stuffs too many methods into it to extend its functionality. A better approach is to have an external class that knows how to extend it without changing the original code much.
The Visitor pattern can be easily described by using examples from your everyday life. In the case of the household plumbing problem, you don't want to learn how to fix plumbing ...
Get Pro Objective-C Design Patterns for iOS 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.