Summary

In this chapter, we've covered five of the most popular behavioral patterns and how to implement them effectively in Swift. These behavioral patterns will help you to decouple your programs in an effective and maintainable way.

When needing to isolate algorithms from the data they consume, you can use strategies and visitors. As object behaviors grow, you can refactor using the state patternPersistence can be represented through the memento pattern, and, finally, the observer pattern helps when passing information around the program.

We've made great use of some advanced and unique features of Swift: protocols, extensions, generics, and immutable value types, which we will dig deeper into in the next chapter.