Chapter 7. Of Visitors and Chains of Responsibilities

In this chapter, we will look at two important design patterns, namely visitors and chains of responsibilities. These patterns help us model real-world scenarios in a pretty neat fashion. Let's first look at the problem domain.

Rakesh and Nita are happily married. One fine evening, Rakesh gets pleasantly surprised as Prakash comes visiting. Prakash is his childhood buddy and is in town on business. Prakash gets to know of Rakesh living in the same town and comes home, and the buddies meet after a span of many years. Prakash is meeting his friend's wife for the first time, though. They greet each other, well, a little formally. Prakash and Rakesh, on the other hand, back slap each other and enquire ...

Get Scala Functional Programming Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.