Software Architecture: Layered Model (MVC, n-Tier)
This post is a definition of terms for the layered model – including exam questions, core elements, and tags.
In a Nutshell
Layered models structure software into logically separated layers (UI/Logic/Data). Typical representatives are MVC and n-Tier, which promote modularity, maintainability, and testability.
Compact Technical Description
In the n-Tier model (usually 3-Tier), there are at least three layers:
- Presentation
- Business Logic
- Data Storage
MVC (Model-View-Controller) separates:
- View (Presentation)
- Controller (Control)
- Model (Data Model)
Data flows in a controlled manner through the layers, so that undesired dependencies are avoided. In practice, layered models are often implemented through frameworks (Angular, Spring, .NET).
Exam-Relevant Key Points
- Separation of presentation, logic, data access
- MVC = View, Controller, Model
- n-Tier = logical architecture with 2–n layers
- Clean separation of responsibilities (IHK-relevant)
- Facilitates testability and interchangeability (practical relevance)
- Reduces attack surface through defined interfaces (security aspect)
- Saves maintenance costs in the long run (cost-effectiveness)
- Architecture must be documented in an understandable manner (documentation requirement)
Core Components
- Presentation layer (UI)
- Logic/Controller layer
- Data layer/Repository
- Model classes (MVC)
- Interfaces between layers
- Validation and error handling
- Frameworks/Middleware
- Service Layer (e.g., REST)
- Authentication/Authorization
- Unit Testing per layer
Simple Practical Example (MVC)
Model: Product(name, price)
View: HTML template
Controller: processes click on "add to cart" and updates Model
Advantages and Disadvantages
Advantages
- Clearly structured codebase
- Better testability through loose coupling
- Reusable modules
- Parallel development in the team
Disadvantages
- Overhead in small projects
- Higher initial effort
- Complexity due to additional layers
Typical Exam Questions (with Short Answers)
- Goal of a layered model? Separation of responsibilities and improved maintainability.
- Three layers in 3-Tier? Presentation, Business Logic, Data Storage.
- What does the Controller do in MVC? Processes user actions and mediates between View and Model.
- How does MVC improve testability? Components can be tested in isolation.
Glossary
| Term | Definition |
|---|---|
| Layered Model | Separation of responsibilities into layers |
| MVC | Model-View-Controller for UI structuring |
| n-Tier | multi-layered architecture with at least three layers |
Free Response
In IHK projects, it is important that each layer only knows the adjacent layer and no “shortcuts” (e.g., database access from the View) occur. For REST backends, the separation Controller/Service/Repository is often standard.
Learning Strategy
- Draw a layer diagram for a mini-app.
- Build a small MVC app in a framework.
- Analyze architecture diagrams and find layer violations.
- Avoid logic in the View.
Topic Analysis
- Technical Core: Separation of Concerns
- Challenges: Dependencies, Boundaries
- Security: Encapsulation of sensitive data
- Documentation: Architecture diagrams
- Cost-effectiveness: Reduce maintenance costs
Further Information
- https://learn.microsoft.com/en-us/aspnet/mvc/overview/overview
- https://www.baeldung.com/spring-service-layer