Chain of Responsibility
I'm a horrible software architect, and I don't particularly appreciate speaking with people. Hence, while sitting in The Ivory Tower (that's the name of the cafe I often visit), I wrote a small web application. If a developer has a question, they shouldn't approach me directly, oh no! They'll need to send me a proper request through this system and I shall only answer them if I deem their request worthy.
A filter chain is a ubiquitous concept in web servers. Usually, when a request reaches you, it's expected that the following is true:
- Its parameters have already been validated.
- The user has already been authenticated, if possible.
- User roles and permissions are known and the user is authorized to perform an action.
So, the code I initially wrote looked something like this:
data class Request(val email: String, val question: String) fun handleRequest(r: Request) { // Validate...