Organisation that lasts.
WHAT THE COMMON LAYERS ARE
Routing, mapping addresses to handlers Handlers, dealing with the request and response Services, containing business logic Data access, talking to the database Models, describing data
WHY SEPARATE THEM
Each can be tested, replaced and understood independently.
WHAT TO KEEP OUT OF HANDLERS
Business rules Direct database queries
WHAT TO KEEP OUT OF DATA ACCESS
Business rules.
WHAT TO ORGANISE BY
Feature, rather than by layer, in larger applications.
WHY
Files that change together should sit together.
WHAT TO AVOID
Very large files Circular dependencies between modules Business logic duplicated across handlers
WHAT TO ESTABLISH EARLY
Conventions for naming, structure and where things belong.
WHY
They are difficult to introduce later.
WHAT TO WRITE DOWN
Those conventions, and the reasoning.
WHAT TO REVIEW
Whether the structure still matches how the application has grown.
WHAT TO RESIST
Restructuring for its own sake.