O'Reilly logo

Swift 2 Design Patterns by Julien Lange

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Behavioral Patterns – Visitor, Interpreter, and Memento

In this chapter, we will complete our discovery trip of the 23 Gang of Four patterns. Now, let's have a look at the three last design patterns of the behavioral patterns category. They are as follows:

  • The visitor pattern
  • The interpreter pattern
  • The memento pattern

The visitor pattern

In this section, we will talk about the visitor pattern, which allows us to separate data and their associated treatments.

Roles

The visitor pattern allows us to externalize and centralize the actions that must be executed on object; these objects cannot have any links between them.

These actions will not be implemented in the class of the objects but in external classes.

So, this allows us to add any action ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required