1 / 12

The Visitor Design Pattern

The Visitor Design Pattern. What ’ s It All About?. Allows for new operations to be defined and used on elements of an object structure with out changing the contents of those elements. The Key is Double Dispatch. Where Applicable. Rarely Changing Object Structures Using Unrelated Operations

agoo
Télécharger la présentation

The Visitor Design Pattern

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Visitor Design Pattern

  2. What’s It All About? • Allows for new operations to be defined and used on elements of an object structure with out changing the contents of those elements. • The Key is Double Dispatch

  3. Where Applicable • Rarely Changing Object Structures • Using Unrelated Operations • Many Classes with Differing Interfaces

  4. How it Works • Concrete Object Structure • Assume Rarely Changing • Bank Accounts

  5. Add an Inquiry Operation • Inquiry to Display Accounts • Don’t Want to Change Structure • Create a Visitor Structure • Account Visitor

  6. Account Visitor Interface

  7. Inquiry Visitor

  8. Account Structure Change

  9. Account Interface

  10. Checking Account

  11. Savings Account

  12. Main Method

More Related