SlideShare una empresa de Scribd logo
1 de 11
Matt Hidinger Blog:           http://matthidinger.com Twitter:     @MattHidinger
Putting business value back to the core of our applications Onion Architecture
Traditional 3-layer Architecture UI Utilities / Common / Shared ASP.NET AutoMapper Core / BLL StructureMap Inftrastructure / DAL nHibernate /LINQ to SQL Log4Net DB
Very easy for developers over time to put more and more business logic in the UI layer Counter-productive to build your application on top of a specific technology that is sure to change over time Logic is easily scattered all over, locating code becomes a major effort. Developers over time struggle to determine where code should go… DAL? BLL? Utilities? Business logic has many tentacles extending from it (directly and indirectly) Library explosion: Makes it easy take a dependency without putting much thought into it, and now it’s littered all over the code base Problems with Traditional Architecture
Inverted Dependencies UI Utilities / Common / Shared ASP.NET Core / BLL AutoMapper Infrastructure / DAL nHibernate /LINQ to SQL StructureMap Log4Net DB
Onion Architecture with Relative Sizes ASP.NET UI Dependency Resolution  (Utilities) Core(BLL) AutoMapper StructureMap nHibernate /LINQ to SQL Infrastructure (DAL) DB Log4Net
True loose coupling between layers/components Limit re-write necessity over time, business value-adding logic is entirely self-contained Application becomes very portable – next version of .NET or an entirely new language/platform Business logic has no dependency tentacles (aside from your platform dependencies) Architecture is more easily sustained over time, developers know exactly where components go, a lot of guesswork is removed Infrastructure is free to use any data access library or external web services to do its work UI and Data Access “layers” become much smaller, deal strictly with technology-related code No more need for Common/Shared/Utilities project  Compiler enforces dependencies boundaries, impossible for Core to reference Infrastructure Benefits of Onion Architecture
ProductsControllerBrowser hits: /Products/List IUserSession User Interface Application Services HttpUserSession<<class>> Domain Services IProductRepository Dependency Resolution ProductRepository<<class>> Domain Model Application Core DB Infrastructure
Draw application/system using concentric circles, can only take dependency on something provided in an inner layer Take ownership of your interfaces Declare the API of the dependency (abstraction) in the inner layer, push implementation outward Direction of dependency is toward the center Externalize all technology related code Push complexity as far outward as possible Guiding Principles User Interface Application Services Domain Services Dependency Resolution Domain Model Application Core DB Infrastructure
Show us some code already… Demo!

Más contenido relacionado

La actualidad más candente

Domain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationDomain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationOğuzhan Soykan
 
From Monolithic to Microservices
From Monolithic to Microservices From Monolithic to Microservices
From Monolithic to Microservices Amazon Web Services
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsAraf Karsh Hamid
 
Clean architecture with ddd layering in php
Clean architecture with ddd layering in phpClean architecture with ddd layering in php
Clean architecture with ddd layering in phpLeonardo Proietti
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architectureThe Software House
 
Monoliths and Microservices
Monoliths and Microservices Monoliths and Microservices
Monoliths and Microservices Bozhidar Bozhanov
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applicationsFabricio Epaminondas
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slidesthinkddd
 
Hexagonal Architecture
Hexagonal ArchitectureHexagonal Architecture
Hexagonal ArchitectureMarcelo Cure
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecturetyrantbrian
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroFabrício Rissetto
 
Azure App Service
Azure App ServiceAzure App Service
Azure App ServiceBizTalk360
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introductionwojtek_s
 
Domain driven design and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven developmentDmitry Geyzersky
 
APIs in a Microservice Architecture
APIs in a Microservice ArchitectureAPIs in a Microservice Architecture
APIs in a Microservice ArchitectureWSO2
 

La actualidad más candente (20)

Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
 
Domain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationDomain Driven Design(DDD) Presentation
Domain Driven Design(DDD) Presentation
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
From Monolithic to Microservices
From Monolithic to Microservices From Monolithic to Microservices
From Monolithic to Microservices
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
 
Clean architecture with ddd layering in php
Clean architecture with ddd layering in phpClean architecture with ddd layering in php
Clean architecture with ddd layering in php
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
Monoliths and Microservices
Monoliths and Microservices Monoliths and Microservices
Monoliths and Microservices
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slides
 
Hexagonal Architecture
Hexagonal ArchitectureHexagonal Architecture
Hexagonal Architecture
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to Hero
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Azure App Service
Azure App ServiceAzure App Service
Azure App Service
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Domain driven design and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven development
 
APIs in a Microservice Architecture
APIs in a Microservice ArchitectureAPIs in a Microservice Architecture
APIs in a Microservice Architecture
 

Destacado

Domain Driven Design Through Onion Architecture
Domain Driven Design Through Onion ArchitectureDomain Driven Design Through Onion Architecture
Domain Driven Design Through Onion ArchitectureBoldRadius Solutions
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API PlatformJohannes Ridderstedt
 
Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup
Applying Domain-Driven Design to APIs and Microservices  - Austin API MeetupApplying Domain-Driven Design to APIs and Microservices  - Austin API Meetup
Applying Domain-Driven Design to APIs and Microservices - Austin API MeetupLaunchAny
 
API Design Methodology - Mike Amundsen, Director of API Architecture, API Aca...
API Design Methodology - Mike Amundsen, Director of API Architecture, API Aca...API Design Methodology - Mike Amundsen, Director of API Architecture, API Aca...
API Design Methodology - Mike Amundsen, Director of API Architecture, API Aca...CA API Management
 
Api architectures for the modern enterprise
Api architectures for the modern enterpriseApi architectures for the modern enterprise
Api architectures for the modern enterpriseCA API Management
 
Domain Driven Design using Laravel
Domain Driven Design using LaravelDomain Driven Design using Laravel
Domain Driven Design using Laravelwajrcs
 
Designing APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignDesigning APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignLaunchAny
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksPhill Sparks
 

Destacado (8)

Domain Driven Design Through Onion Architecture
Domain Driven Design Through Onion ArchitectureDomain Driven Design Through Onion Architecture
Domain Driven Design Through Onion Architecture
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API Platform
 
Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup
Applying Domain-Driven Design to APIs and Microservices  - Austin API MeetupApplying Domain-Driven Design to APIs and Microservices  - Austin API Meetup
Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup
 
API Design Methodology - Mike Amundsen, Director of API Architecture, API Aca...
API Design Methodology - Mike Amundsen, Director of API Architecture, API Aca...API Design Methodology - Mike Amundsen, Director of API Architecture, API Aca...
API Design Methodology - Mike Amundsen, Director of API Architecture, API Aca...
 
Api architectures for the modern enterprise
Api architectures for the modern enterpriseApi architectures for the modern enterprise
Api architectures for the modern enterprise
 
Domain Driven Design using Laravel
Domain Driven Design using LaravelDomain Driven Design using Laravel
Domain Driven Design using Laravel
 
Designing APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignDesigning APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven Design
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill Sparks
 

Similar a Onion Architecture

Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arpGary Pedretti
 
Containerize, PaaS, or Go Serverless!?
Containerize, PaaS, or Go Serverless!?Containerize, PaaS, or Go Serverless!?
Containerize, PaaS, or Go Serverless!?Phil Estes
 
Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsNuno Caneco
 
Html5 workshop part 1
Html5 workshop part 1Html5 workshop part 1
Html5 workshop part 1NAILBITER
 
Webinar - Mobile Apps: Monolithic to Serverless
Webinar - Mobile Apps: Monolithic to ServerlessWebinar - Mobile Apps: Monolithic to Serverless
Webinar - Mobile Apps: Monolithic to ServerlessOpenXcell Technolabs
 
IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...
IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...
IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...darwinodb
 
Best software development tools in 2021
Best software development tools in 2021Best software development tools in 2021
Best software development tools in 2021Samaritan InfoTech
 
Cloud Application Development Lifecycle
Cloud Application Development LifecycleCloud Application Development Lifecycle
Cloud Application Development LifecycleSuhas Kelkar
 
Anand_Honeywell_11yrs
Anand_Honeywell_11yrsAnand_Honeywell_11yrs
Anand_Honeywell_11yrsAnand Patil
 
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid ApplicationsA Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applicationsajithranabahu
 
Light-up-your-out-of-the-box LightSwitch Application
Light-up-your-out-of-the-box LightSwitch ApplicationLight-up-your-out-of-the-box LightSwitch Application
Light-up-your-out-of-the-box LightSwitch ApplicationBoulos Dib
 
Build Event-Driven Microservices with Confluent Cloud Workshop #1
Build Event-Driven Microservices with Confluent Cloud Workshop #1Build Event-Driven Microservices with Confluent Cloud Workshop #1
Build Event-Driven Microservices with Confluent Cloud Workshop #1confluent
 
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
 Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e... Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...VMware Tanzu
 

Similar a Onion Architecture (20)

Cloud to Edge
Cloud to EdgeCloud to Edge
Cloud to Edge
 
DevCon5 (July 2014) - Acision SDK
DevCon5 (July 2014) - Acision SDKDevCon5 (July 2014) - Acision SDK
DevCon5 (July 2014) - Acision SDK
 
Trends in Technology
Trends in TechnologyTrends in Technology
Trends in Technology
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 
Food borne human diseases
Food borne human diseasesFood borne human diseases
Food borne human diseases
 
Introduction To Symfony
Introduction To SymfonyIntroduction To Symfony
Introduction To Symfony
 
Containerize, PaaS, or Go Serverless!?
Containerize, PaaS, or Go Serverless!?Containerize, PaaS, or Go Serverless!?
Containerize, PaaS, or Go Serverless!?
 
Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystems
 
Html5 workshop part 1
Html5 workshop part 1Html5 workshop part 1
Html5 workshop part 1
 
Webinar - Mobile Apps: Monolithic to Serverless
Webinar - Mobile Apps: Monolithic to ServerlessWebinar - Mobile Apps: Monolithic to Serverless
Webinar - Mobile Apps: Monolithic to Serverless
 
IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...
IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...
IBM ConnectED SPOT104: Lightning-Fast Development of Native Mobile Apps for I...
 
Best software development tools in 2021
Best software development tools in 2021Best software development tools in 2021
Best software development tools in 2021
 
Cloud Application Development Lifecycle
Cloud Application Development LifecycleCloud Application Development Lifecycle
Cloud Application Development Lifecycle
 
Anand_Honeywell_11yrs
Anand_Honeywell_11yrsAnand_Honeywell_11yrs
Anand_Honeywell_11yrs
 
Mvc3 part1
Mvc3   part1Mvc3   part1
Mvc3 part1
 
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid ApplicationsA Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
A Domain Specific Language for Enterprise Grade Cloud-Mobile Hybrid Applications
 
Charles harper Resume
Charles harper ResumeCharles harper Resume
Charles harper Resume
 
Light-up-your-out-of-the-box LightSwitch Application
Light-up-your-out-of-the-box LightSwitch ApplicationLight-up-your-out-of-the-box LightSwitch Application
Light-up-your-out-of-the-box LightSwitch Application
 
Build Event-Driven Microservices with Confluent Cloud Workshop #1
Build Event-Driven Microservices with Confluent Cloud Workshop #1Build Event-Driven Microservices with Confluent Cloud Workshop #1
Build Event-Driven Microservices with Confluent Cloud Workshop #1
 
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
 Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e... Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
 

Último

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Onion Architecture

  • 1. Matt Hidinger Blog: http://matthidinger.com Twitter: @MattHidinger
  • 2. Putting business value back to the core of our applications Onion Architecture
  • 3. Traditional 3-layer Architecture UI Utilities / Common / Shared ASP.NET AutoMapper Core / BLL StructureMap Inftrastructure / DAL nHibernate /LINQ to SQL Log4Net DB
  • 4. Very easy for developers over time to put more and more business logic in the UI layer Counter-productive to build your application on top of a specific technology that is sure to change over time Logic is easily scattered all over, locating code becomes a major effort. Developers over time struggle to determine where code should go… DAL? BLL? Utilities? Business logic has many tentacles extending from it (directly and indirectly) Library explosion: Makes it easy take a dependency without putting much thought into it, and now it’s littered all over the code base Problems with Traditional Architecture
  • 5. Inverted Dependencies UI Utilities / Common / Shared ASP.NET Core / BLL AutoMapper Infrastructure / DAL nHibernate /LINQ to SQL StructureMap Log4Net DB
  • 6. Onion Architecture with Relative Sizes ASP.NET UI Dependency Resolution (Utilities) Core(BLL) AutoMapper StructureMap nHibernate /LINQ to SQL Infrastructure (DAL) DB Log4Net
  • 7. True loose coupling between layers/components Limit re-write necessity over time, business value-adding logic is entirely self-contained Application becomes very portable – next version of .NET or an entirely new language/platform Business logic has no dependency tentacles (aside from your platform dependencies) Architecture is more easily sustained over time, developers know exactly where components go, a lot of guesswork is removed Infrastructure is free to use any data access library or external web services to do its work UI and Data Access “layers” become much smaller, deal strictly with technology-related code No more need for Common/Shared/Utilities project Compiler enforces dependencies boundaries, impossible for Core to reference Infrastructure Benefits of Onion Architecture
  • 8. ProductsControllerBrowser hits: /Products/List IUserSession User Interface Application Services HttpUserSession<<class>> Domain Services IProductRepository Dependency Resolution ProductRepository<<class>> Domain Model Application Core DB Infrastructure
  • 9.
  • 10. Draw application/system using concentric circles, can only take dependency on something provided in an inner layer Take ownership of your interfaces Declare the API of the dependency (abstraction) in the inner layer, push implementation outward Direction of dependency is toward the center Externalize all technology related code Push complexity as far outward as possible Guiding Principles User Interface Application Services Domain Services Dependency Resolution Domain Model Application Core DB Infrastructure
  • 11. Show us some code already… Demo!

Notas del editor

  1. The diagram only shows a database at the bottom, but there could be web services, XML files, etcWhy should we build our application on top of technology, which we know changes all the time?Transitive dependencies – if you depend on something, which depends on something else, you have a transitive dependency on that thingNot necessarily bad, or good, it just is
  2. Business logic in the middle, depends on nothing. Promote business logic to the core of the application
  3. BLL becomes core, holds ALL logic unique to the businessDAL becomes Infrastructure, responsible for technical implementation details onlyUtilities becomes Dependency ResolutionAll other layers become very thin
  4. Should I create a factor for this or just new up my dependency?Where should the factory class go?Do I need to provide an interface for my component?Am I allowed to use classes out of this namespace?