Why layers
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
explain why we split code into layers.
Planned topics
- One class doing HTTP, rules, and data access is hard to read, test, and change.
- Each layer has one job and talks only to the layer below.
- Flow: controller → service → repository; the domain model is shared by service and repository.
- Layers let you change one part (say, the database) without rewriting the rest.
Draft outline details
Demonstration
a diagram: HTTP → Controller → Service → Repository → storage, with arrows pointing down only.
Check your understanding
Should a repository call a controller?
Show answer
No; dependencies go downward only.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.