Onion Architecture Flashcards
What is the Onion Architecture in software engineering
Onion Architecture is comprised of multiple concentric layers interfacing each other towards the core that represents the domain.
What does the achitecture depend on?
The architecture does not depend on the data layer as in classic multi-tier architectures, but on the actual domain models
Which SOLID principle does it depend on?
Onion Architecture is based on the inversion of control principle
What problem does it resolve?
Seperation of concerns.
As per traditional architecture, the UI layer interacts to business logic, and business logic talks to the data layer, and all the layers are mixed up and depend heavily on each other. In 3-tier and n-tier architectures.
How does it solve it?
Loose coupling
What are the layers?
- Domain
- Application
- Infrastructure
- User Interface
What is the Domain Layer?
Center of the architecture representing business and behaviour objects
What is the Application Layer?
Orchestrates the domain objects
What is the Infrastructure Layer?
External concerns such as data access and logging
What is the User Interface Layer?
Presenting information to user and handling user input
Gives an example of the kind of things in the Domain Layer?
- Entities
- Domain Services
- Repository Interfaces
ie DB entities
Gives an example of the kind of things in the Application Layer?
- Validating User Input
- Managing Transactions
- Coordinating multile domain objects to implement a business process
ie User, UserService
Gives an example of the kind of things in the Infrastructure Layer?
- Data Persistence
- Caching
- Messaging
ie Repository, Unit Of Work, Email
Gives an example of the kind of things in the User Interface Layer?
- Screens
- Forms
- Controls
ie UserAdmin, UserAdd, UserItem
Is Onion Architecture the same as Clean Architecture?
They are similar but not the same.
See future cards on Clean Architecture