Why: the goal or problem
Screen changes, business rules and storage edits are tangled together. Separate responsibilities so a change has a clearer home.
How: work toward a solution
- Fictional single process: reader R1, A17 unsaved; memory or embedded database.
- HTTP or CLI presentation imports and calls application validation, which imports and calls persistence. This closed-layer example forbids skipping layers.
- Saved returns upward: 0 → 1 entries; repeat → 1. Empty IDs or failure before writing → 0; retry after correction.
Switching HTTP to CLI leaves validation in place.
Illustrative example
Three responsibilities, one process
R1 · A17 · initially unsaved
One process · dotted enclosure
Presentation
HTTP / CLI
Receives IDs; displays Saved
Source dependency ↓
Runtime call ↓
Application
SaveArticle(R1, A17)
Validates IDs; coordinates saving
Source dependency ↓
Runtime call ↓
Persistence
Memory / Embedded database
Records one saved entry
↑ Saved returns: persistence → application → presentation
Closed-layer example: no skipping. Replace HTTP with CLI; validation stays in the application.
- Save → repeat: 0 → 1 → 1 entries; return Saved.
- From empty: empty IDs or failure before writing → 0. Retry after correction.
HTTP / CLI and memory / embedded database are alternatives; no data migration is implied.
What: the concept
Layered architecture separates responsibilities and constrains dependencies. Logical layers need not be separate machines. Microsoft
Pass-through layers add ceremony. Ports can invert storage dependencies. Folder names alone enforce nothing.
Discuss this idea
Comments are shared across languages. GitHub login required to post.