Description
The current REST controller has grown beyond a thin HTTP layer and now mixes request handling, business orchestration, response assembly, link generation, request mapping, and resource embedding in one file. This makes the code difficult to read, test, and change safely.
Please describe your situation in few words here.
Files like ReleaseController currently handles multiple unrelated capabilities in a single class, including release listing and lookup, create/update/delete flows, attachment operations, etc . This violates separation of concerns. The controller is no longer a thin adapter layer and contains logic that belongs in dedicated controllers, assemblers, and application services.
Impact over the system
- Large file size increases cognitive load.
- Changes in one area can unintentionally affect unrelated endpoints.
- Tests become broader and harder to isolate.
- Reuse is poor because controller logic is tightly coupled.
- HAL/resource assembly logic is duplicated or embedded in HTTP classes.
- Future enhancements become slower and riskier.
Suggested Architecture
- The
Rest Controllers must be improvised to call service based operations majorly including :
- business orchestration
- HAL/resource construction
- request-to-domain mapping
- auth/user resolution/pagination parsing
Benifits :
Readable controllers , Structured and modular code , Better testability , Lower regression risk and Easier feature expansion for the future .
Description
The current REST controller has grown beyond a thin HTTP layer and now mixes request handling, business orchestration, response assembly, link generation, request mapping, and resource embedding in one file. This makes the code difficult to read, test, and change safely.
Please describe your situation in few words here.
Files like
ReleaseControllercurrently handles multiple unrelated capabilities in a single class, including release listing and lookup, create/update/delete flows, attachment operations, etc . This violates separation of concerns. The controller is no longer a thin adapter layer and contains logic that belongs in dedicated controllers, assemblers, and application services.Impact over the system
Suggested Architecture
Rest Controllersmust be improvised to call service based operations majorly including :Benifits :
Readable controllers , Structured and modular code , Better testability , Lower regression risk and Easier feature expansion for the future .