Layered Application Architecture: Sub-Layer Hierarchy and Data Models
Layered architecture structures applications by dividing functionality into isolated layers: a facade layer for external access, a logic layer for business rules, and a persistence layer for data storage. Each layer breaks down into sub-layers—facade, logic, and data access—enabling one-way interactions between layers and two-way data exchange between models.
Core Components of a Single-Tier Application
A single-tier application combines three key functional groups:
- Layered functionality: Isolated layers with one-way interactions between adjacent layers and sub-layers.
- Cross-cutting functionality: Shared mechanisms available to all layers, like logging or security.
- Dataflow functionality: Data transfer operations, including:
- Data mapping to transform between data models.
- Data binding to link data with the UI.
- Data serialization for exchanging with external systems via data transfer channels.
Layer interactions follow a strict hierarchy: adjacent layers exchange data one-way, while data models communicate two-way. The application connects with external consumers (data consumers/producers) through an application input interface and with external data sources (local or remote) via an application output interface.
Local data sources include files, USB/COM/LPT ports. Remote sources cover databases, FTP, LDAP, web services, and message brokers.
Layer and Sub-Layer Structure
Each layer includes functionality and associated data models. Sub-layers consist of:
- Facade sub-layer: External API (public methods).
- Logic sub-layer: Internal layer logic.
- Data access sub-layer: Access to external sources.
Interaction examples:
- Facade layer: UI event handlers or API endpoints.
- Logic layer: Coordinates business logic (application logic).
- Persistence layer: Data access objects (DAOs).
The logic sub-layer of the facade layer generates UI content (e.g., view templates in ASP.NET MVC) and validators (like UniqueValueValidator querying the database via the data access sub-layer).
The logic sub-layer of the logic layer implements domain logic, interacting with persistence for reference data or in recursive algorithms.
External Interfaces and Application Boundaries
- Application upper boundary: Gateway to external consumers via input interface (visual forms, server-side sockets, timers).
- Application lower boundary: Gateway to data sources via output interface (sockets, database drivers).
Data access from facade/logic layers:
- Direct to local sources.
- Via output interface to remote sources.
- Through persistence layer to databases.
The persistence layer focuses on storing and managing persistent data.
Architecture Examples
Structural diagrams illustrate use in web services, report viewers, and ASP.NET MVC.
In a report viewer:
- Facade sub-layer: Visual form with report viewer component.
- Logic sub-layer: Report generator using templates (report templates) and data from the data access sub-layer.
- Data access sub-layer: Queries to persistence layer for report data.
Multi-tier architectures extend single-tier: each tier is a layered application, covering Client-Server, Event-Driven, Pipes and Filters, SOA, and Microservices.
Key Takeaways
- Layering (facade, logic, persistence) ensures isolation and scalability.
- Sub-layers (facade, logic, data access) standardize APIs and logic.
- One-way layer interactions minimize dependency cycles.
- Dataflow (mapping, binding, serialization) streamlines data transfers.
- Clear application boundaries (input/output interfaces) separate internal and external contexts.
— Editorial Team
No comments yet.