Principles and Architecture / Design patterns / Behavioral
Chain of responsibility
Original notes by SunDiaL · View English source
The problem: Your code becomes messy because of a lot of checks you must do before getting to the important part. The solution: Extract each check/step in a separate "handler" class.
An example: The middleware pipeline in a Web API.