3.4 The Chain of Responsibility Pattern
Does your application have input that should be handled in a different way depending on the type of the input? The Chain of Responsibility pattern can free us from the anti-pattern of gigantic if...else conditional blocks. To start, the input is passed to the first handle. Can the first handler handle the data? If not, then pass the data to the next handler, and so on.