I've been meaning to write something similar - perhaps with different naming, but more or less the same ideas at heart.
Each controller action or GraphQL mutation should do nothing than calling a UseCase and handle the outcome.
100% this! I feel that as a Rails community we more or less figured out what should be in the model, in the view etc., but we still struggle with controllers. And, inevitably, they end up as a convoluted mess. Your approach helps to extract the actual logic very nicely! Controller should only serve as a proxy from HTTP world to application world IMO.
I've been meaning to write something similar - perhaps with different naming, but more or less the same ideas at heart.
100% this! I feel that as a Rails community we more or less figured out what should be in the model, in the view etc., but we still struggle with controllers. And, inevitably, they end up as a convoluted mess. Your approach helps to extract the actual logic very nicely! Controller should only serve as a proxy from HTTP world to application world IMO.
Hi Paweł,
nice to hear that you liked the article :)
I'm absolutely on your side: Controllers should handle authentication, rendering, redirects and notifications, but should be free of business logic.