Chain of Responsibility: The Coin Sorter

When every voice command has to pass a night-time check, a someone's-home check and a permission check, one function full of ifs grows with every new check and gets copied for every new device; a Chain of Responsibility makes each check its own link that stops the command or passes it on, so checks can be added, reordered and reused.

By

Updated

Cheat sheet: Chain of Responsibility: The Coin Sorter
Category
Data Structures
Level
Journeyman
Tags
Chain of Responsibility, Code Smell, coupling, OOP