Chain of Responsibility(behavioral design pattern) help you pass requests along a chain of handlers. Each handler decides either to process the request or to pass it to the next handler in the chain.
In a company, device purchasing is important. It needs the approval from
purchasing officer. The approval route for mortgage applications is
from purchasing manager to senior manager then to director,
where approval limits are:
Managers - 0 to 30k
Senior Managers - 30k to 50k
Director - anything over 50k
Implementation steps:
1. Create a Purchasing class, it contains amount property
2. Create an Approver abstract class, it contains setNextApprover(approver)
and Approve(purchasing) method
3. Create 3 classes: Manager, SeniorManager and Director
that extend Approver class