0% found this document useful (0 votes)
17 views35 pages

Understanding Foundational Architectural Principles Slides

Uploaded by

Borce Markovski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views35 pages

Understanding Foundational Architectural Principles Slides

Uploaded by

Borce Markovski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Understanding Foundational

Architectural Principles

Gill Cleeren
CTO Xpirit Belgium

@gillcleeren | xpirit.com/gill
Overview
Foundational design principles
Different application architecture styles
Understanding Clean Architecture
Foundational Architectural Principles
Important Design Principles

Dependency Separation of
Single responsibility
inversion concerns

Persistence
DRY
ignorance
Dependency Inversion
- Decoupling modules

Dependencies should be pointing to


abstractions
- Typically top to bottom
Helps with building more loosely-coupled
applications
Typical Approach

Class A Class B Class C


Adding Dependency Inversion

Class A Interface B Interface C

Class B Class C
Separation of Concerns

Split into blocks of functionality


- Each covering a concern

More modular code


- Encapsulation within a module
Typical layered application

Easier to maintain
Single Responsibility

OO terminology
Each block should just have one single
responsibility which it encapsulates
More, new classes are created

Can be extended to application-level


- Different layers have their own responsibility
DRY
(aka Don’t Repeat Yourself)
Less code repetition

Easier to make changes


Persistence Ignorance
POCO
Domain classes
shouldn’t be
impacted by how
they are persisted
Typically requires base
class or attributes
Foundational Patterns
These will come in useful
throughout this entire course!
Different Application Architecture Styles
Different Types of Application Architecture

All-in-one
architecture
All-in-one Architecture

Contained typically in one (large) Visual Studio project

File à New Project

“Layers” are folders

Can be difficult to maintain


Different Types of Application Architecture

All-in-one Layered architecture


architecture
Layered Architecture

Split according to concern

Promote reuse

Easier to maintain

Pluggable
Typical Layered Architecture

Presentation layer

Business logic layer

Data access layer


Disadvantages of
Layered Architecture
Still “coupling” between layers

Behaves as single application


Understanding Clean Architecture
Different Types of Application Architecture

All-in-one Layered architecture Clean architecture


architecture
Introducing
Clean Architecture
Based on design principles

Separate concerns

Create maintainable and testable


application code
Variation on hexagonal and onion architecture
- Introduced in 2012

Separation of concerns
Loose coupling
Independent of “external” influences
- UI
- Database
Circular Design
Different circles for different “layers”
User interface
Application Core
- Abstractions (high-level)
- Interfaces and entities
Interfaces - Business logic at the center of the
Core
Entities
application (use-cases)
- Agnostic to outer circles
Application Core - Has no dependencies on external
influences
Infrastructure
Understanding Clean Architecture
Outer circles are infrastructure
User interface
(mechanisms)
- Depends on Core
- Implements interfaces from Core

Interfaces Dependencies are inverted


Entities
- Pointing inwards
UI
Application Core - Depends on Core

Infrastructure
Understanding Clean Architecture

User interface

Interfaces
Entities

Application Core

Infrastructure
Two Important Principles

Dependency Inversion Mediator


Who Goes Where?
Core
User interface
- Entities
- Interfaces
- Core
Interfaces - Infrastructure
Entities - Services
- Exceptions
Application Core No dependency to any Infrastructure-
related code or package
Infrastructure
Understanding Clean Architecture
Infrastructure
User interface
- Data access (EF Core)
- Logging
- API Clients
Interfaces - Identity
Entities - File access

Application Core

Infrastructure
Understanding Clean Architecture
UI
User interface
- API/MVC/Razor
- Specific ASP.NET Core items
- Middleware
Interfaces - Filters
Entities - Interact with services through MediatR
- Loose coupling
Application Core - Lightweight controllers

Infrastructure
Clean Architecture Benefits

Independent of UI or used frameworks

No knowledge of used database

Testable and maintainable


High-level Code Organization
The end result…
Testable and maintainable
application code

Not for every application though!


Summary
Reviewed foundational design principles
Clean architecture relies on these
- Will result in more testable and
maintainable applications
Up Next:

Creating the application core

You might also like