Chapter plan
What you will complete
01Controller → Service → RepositorySplit one fat controller into three collaborating layers and see what each is allowed to know about the others.Fat controller problemsLayer responsibilitiesDependency direction 25 min02Organizing Packages: Feature vs LayerPackage-by-layer groups all controllers together; package-by-feature groups one capability end to end—each scales differently as the codebase grows.Package-by-layerPackage-by-featureModule boundaries 20 min
Module outcome
Refactor an endpoint-heavy prototype into a layered service where each class has one reason to change.
Mental model
Each layer answers one kind of question: HTTP translation, business decisions, persistence—never all three in one class.
Module checkpoint
Layered Task API
Refactor the REST module tasks API from controller-only code into full layers.
- Thin controllers with no repository imports
- Business rules tested without Spring
- One package strategy applied consistently
Final module assessment
Ready to prove mastery?
Complete all 50 questions after finishing the module lessons and checkpoint.