Where request handling lives.
WHAT A CONTROLLER DOES
Receives a request, coordinates a response.
WHAT IT SHOULD CONTAIN
Validation, or delegation of it Calls to whatever performs the work A decision about what to return
WHAT IT SHOULD NOT CONTAIN
Business logic Complex database queries Anything reusable elsewhere
WHY
A controller handling one path cannot serve another, so logic inside it cannot be reused or tested independently.
WHAT TO DO INSTEAD
Put the work in dedicated classes, and call them.
WHAT TO KEEP CONTROLLERS
Short. A few lines per action is normal in well-structured applications.
WHAT TO RETURN
A view, a redirect, or data.
WHAT TO USE FOR VALIDATION
Dedicated request classes, which validate before the controller runs.
WHY
The controller only executes when input is already valid.
WHAT TO AVOID
Controllers with many unrelated actions Duplicated logic across controllers
WHAT TO NAME THEM AFTER
The resource they handle.