SlideShare ist ein Scribd-Unternehmen logo
1 von 36
The Clean
Architecture
S Single-responsiblity principle
O Open-closed principle
L Liskov substitution principle
I Interface segregation principle
D Dependency inversion principle
Solid Principles
Single-responsibility principle
A class should have one and only one reason to change,
meaning that a class should have only one job.
Open-closed principle
Objects or entities should be open for extension, but closed
for modification.
Liskov substitution principle
Every subclass/derived class should be substitutable for
their base/parent class.
Interface segregation principle
A class should never be forced to implement an interface
that it doesn't use and a class should never be forced to
implement methods that it doesn't use.
Dependency inversion principle
Entities must depend on abstractions not on concretions. It
states that the high level module must not depend on the
low level module, but they should depend on abstractions.
vs
Design Pattern
Software Architecture
MVC - MVVM - MVP
Design patterns or software architectures?
Design pattern
A design pattern is the re-usable form of a solution to a
design problem. (Singleton - Observer - MVC - MVVM -
MVP)
Software architecture
Software architecture refers to the high level structures of a
software system and the discipline of creating such
structures and systems. (Hexagonal architecture - Onion
architecture - The Clean architecture)
Successful Software
Architecture
Characteristics
Successful Software
Architecture Characteristics
• Testable
• Independent of the UI
• Independent of the Database
• Independent of Frameworks and External Entities
Testable
The business logic layer(s) can be tested without the UI, database, net
Independent of the UI
The UI can be easily modified, without changing the rest of the applica
Independent of the Database
You can swap out Core Data or SQLite, for Realm, Firebase or
something else entirely. Your business logic is not bound to the
database or persistence layer(s).
Independent of External Entities
The architecture does not depend on external libraries. This allows
the team to use them as tools, rather than having to adapt your
application(s) to their limited constraints and rigid conventions.
Why using Clean
Architecture?
To make your code:
The Clean Architecture
Entities are enterprise-wide business rules that encapsulate the most
general business rules, these rules are the least likely to change.
Use cases are also called interactors and stand for application-specific
business rules of the software. This layer is isolated from changes to the
database, common frameworks, and the UI.
Interface adapters convert data from a convenient format for entities and
use cases to a format applicable to databases and the web, for example.
This layer includes Presenters from MVP, ViewModel from MVVM, and
Gateways (also known as Repositories).
Frameworks and drivers are the outermost layer, which consists of the
web framework, database, UI, HTTP client, and so on.
- Interactor (Use Case): Contains application specific business rules.
- Entity: Contains application independent business rules.
- Boundary<I>: Data comes into interactors through boundary (interface/protocol) which is implemented by the
interactor. Data goes out from the interactor to boundaries implemented by other objects.
- Delivery Mechanism: Can be Web, Console application, Mobile App UI, etc
1- User clicks a button (on a web form for example).
2- The delivery mechanism (ex: Web) takes whatever data submitted by the user and stick it into a data
structure which contains only primitives types (Request Model).
3- The request model passed through the input boundary and since the interactor implements the input
boundary, the interactor received that request model.
4- Interactor then uses that request model and controls the dance of the entities (ex: creates the order,
modify the customer, etc).
5- And when it’s done with that, it continues to control the dance of the entities but this time in the opposite
direction as it gather up all the results to create yet another data structure called (Response Model).
6- The response model is passed back out through the output boundary to the delivery mechanism that
implement it and somehow it’s delivered to the user.
-Response Model contains data that was created by the interactor as the result of the use
case, but this data is not presentable, a date for example would be a date object, and the
currency would be a money object.
-Presenter is a class or a set of classes whose job is to take the response model and translate
it into a view model. For example, it takes the date object from the response model and calls
simple data formatter which generates a nice date string that the view model will hold, and
takes the currency from the response model and puts the currency symbol in the view model.
-View Model contains the data that will be used by the view. For example, If there is a button on
the view, the view model has the string that holds the name of that button, and if the button
shouldn’t be active, so it should be grey, the view model holds the boolean that indicates the
status of the button. If there are menu items in the view, the view model has the names of all
the menu items and their order.
-View all it can do is grabbing the data from the view model and put it on the screen. It should
be so stupid so you don’t have to test it. (You can test it with your eyes).
What about the
database?
–Robert C. Martin
“If something changes a lot, it should be a plug-in. If
something doesn’t change very often, it should be
plugged into.”
What about the database?
• The database is a detail, it shouldn’t be the center of your
architecture.
• The database should be a plug-in to the business rules.
• Business rules shouldn’t be written in stored procedures in
the database.
Real Life Example
List contacts use case
• List all the contacts from the local database and from the
phone database.
• Group the contacts by mobile number and remove the
duplicates.
• Present the filtered contacts in a table view.
Questions?
References:
• https://www.youtube.com/watch?v=o_TH-Y78tt4
• https://proandroiddev.com/clean-architecture-data-flow-dependency-rule-
615ffdd79e29
• https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-
architecture.html
• https://medium.freecodecamp.org/a-quick-introduction-to-clean-architecture-
990c014448d2
• https://medium.com/@pxpgraphics/clean-architecture-3fe6907e7441
• https://hackernoon.com/golang-clean-archithecture-efd6d7c43047
• https://rubygarage.org/blog/clean-android-architecture
Thank You!

Weitere ähnliche Inhalte

Was ist angesagt?

Hexagonal Architecture
Hexagonal ArchitectureHexagonal Architecture
Hexagonal ArchitectureMarcelo Cure
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applicationsFabricio Epaminondas
 
2012 the clean architecture by Uncle bob
2012 the clean architecture by Uncle bob 2012 the clean architecture by Uncle bob
2012 the clean architecture by Uncle bob GEORGE LEON
 
Kata: Hexagonal Architecture / Ports and Adapters
Kata: Hexagonal Architecture / Ports and AdaptersKata: Hexagonal Architecture / Ports and Adapters
Kata: Hexagonal Architecture / Ports and Adaptersholsky
 
Hexagonal architecture: how, why and when
Hexagonal architecture: how, why and whenHexagonal architecture: how, why and when
Hexagonal architecture: how, why and whenXoubaman
 
Clean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipClean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipIvan Paulovich
 
The Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureThe Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureNicolas Carlo
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET CoreAvanade Nederland
 
Clean architecture
Clean architectureClean architecture
Clean architectureLieven Doclo
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven DesignDavid Berliner
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net coreSam Nasr, MCSA, MVP
 
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafSpring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafThymeleaf
 
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
 
React js programming concept
React js programming conceptReact js programming concept
React js programming conceptTariqul islam
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)Tom Kocjan
 
Introduction to SOLID Principles
Introduction to SOLID PrinciplesIntroduction to SOLID Principles
Introduction to SOLID PrinciplesGanesh Samarthyam
 

Was ist angesagt? (20)

Hexagonal Architecture
Hexagonal ArchitectureHexagonal Architecture
Hexagonal Architecture
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
 
2012 the clean architecture by Uncle bob
2012 the clean architecture by Uncle bob 2012 the clean architecture by Uncle bob
2012 the clean architecture by Uncle bob
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Kata: Hexagonal Architecture / Ports and Adapters
Kata: Hexagonal Architecture / Ports and AdaptersKata: Hexagonal Architecture / Ports and Adapters
Kata: Hexagonal Architecture / Ports and Adapters
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Hexagonal architecture: how, why and when
Hexagonal architecture: how, why and whenHexagonal architecture: how, why and when
Hexagonal architecture: how, why and when
 
Clean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipClean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software Craftsmanship
 
Hexagonal architecture
Hexagonal architectureHexagonal architecture
Hexagonal architecture
 
The Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureThe Secrets of Hexagonal Architecture
The Secrets of Hexagonal Architecture
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET Core
 
Angular
AngularAngular
Angular
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven Design
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafSpring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
 
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
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Introduction to SOLID Principles
Introduction to SOLID PrinciplesIntroduction to SOLID Principles
Introduction to SOLID Principles
 

Ähnlich wie SOLID Principles and The Clean Architecture

The Clean Architecture
The Clean ArchitectureThe Clean Architecture
The Clean ArchitectureDmytro Turskyi
 
1-SDLC - Development Models – Waterfall, Rapid Application Development, Agile...
1-SDLC - Development Models – Waterfall, Rapid Application Development, Agile...1-SDLC - Development Models – Waterfall, Rapid Application Development, Agile...
1-SDLC - Development Models – Waterfall, Rapid Application Development, Agile...JOHNLEAK1
 
Software design principles - jinal desai
Software design principles - jinal desaiSoftware design principles - jinal desai
Software design principles - jinal desaijinaldesailive
 
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and WorkingIRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and WorkingIRJET Journal
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast trackBinu Bhasuran
 
Pattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecturePattern oriented architecture for web based architecture
Pattern oriented architecture for web based architectureshuchi tripathi
 
Cs 1023 lec 2 (week 1) edit 1
Cs 1023  lec 2 (week 1) edit 1Cs 1023  lec 2 (week 1) edit 1
Cs 1023 lec 2 (week 1) edit 1stanbridge
 
Cs 1023 lec 2 (week 1) edit 1
Cs 1023  lec 2 (week 1) edit 1Cs 1023  lec 2 (week 1) edit 1
Cs 1023 lec 2 (week 1) edit 1stanbridge
 
[2016/2017] Introduction to Software Architecture
[2016/2017] Introduction to Software Architecture[2016/2017] Introduction to Software Architecture
[2016/2017] Introduction to Software ArchitectureIvano Malavolta
 
Object oriented methodologies
Object oriented methodologiesObject oriented methodologies
Object oriented methodologiesnaina-rani
 
Gof design pattern
Gof design patternGof design pattern
Gof design patternnaveen kumar
 
[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software ArchitectureIvano Malavolta
 
software_engg-chap-03.ppt
software_engg-chap-03.pptsoftware_engg-chap-03.ppt
software_engg-chap-03.ppt064ChetanWani
 
object oriented methodologies
object oriented methodologiesobject oriented methodologies
object oriented methodologiesAmith Tiwari
 

Ähnlich wie SOLID Principles and The Clean Architecture (20)

The Clean Architecture
The Clean ArchitectureThe Clean Architecture
The Clean Architecture
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design pattern
Design patternDesign pattern
Design pattern
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
MVC
MVCMVC
MVC
 
1-SDLC - Development Models – Waterfall, Rapid Application Development, Agile...
1-SDLC - Development Models – Waterfall, Rapid Application Development, Agile...1-SDLC - Development Models – Waterfall, Rapid Application Development, Agile...
1-SDLC - Development Models – Waterfall, Rapid Application Development, Agile...
 
Software design principles - jinal desai
Software design principles - jinal desaiSoftware design principles - jinal desai
Software design principles - jinal desai
 
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and WorkingIRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast track
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Pattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecturePattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecture
 
Cs 1023 lec 2 (week 1) edit 1
Cs 1023  lec 2 (week 1) edit 1Cs 1023  lec 2 (week 1) edit 1
Cs 1023 lec 2 (week 1) edit 1
 
Cs 1023 lec 2 (week 1) edit 1
Cs 1023  lec 2 (week 1) edit 1Cs 1023  lec 2 (week 1) edit 1
Cs 1023 lec 2 (week 1) edit 1
 
[2016/2017] Introduction to Software Architecture
[2016/2017] Introduction to Software Architecture[2016/2017] Introduction to Software Architecture
[2016/2017] Introduction to Software Architecture
 
Struts Ppt 1
Struts Ppt 1Struts Ppt 1
Struts Ppt 1
 
Object oriented methodologies
Object oriented methodologiesObject oriented methodologies
Object oriented methodologies
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture
 
software_engg-chap-03.ppt
software_engg-chap-03.pptsoftware_engg-chap-03.ppt
software_engg-chap-03.ppt
 
object oriented methodologies
object oriented methodologiesobject oriented methodologies
object oriented methodologies
 

Kürzlich hochgeladen

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 

Kürzlich hochgeladen (20)

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

SOLID Principles and The Clean Architecture

  • 2. S Single-responsiblity principle O Open-closed principle L Liskov substitution principle I Interface segregation principle D Dependency inversion principle Solid Principles
  • 3. Single-responsibility principle A class should have one and only one reason to change, meaning that a class should have only one job. Open-closed principle Objects or entities should be open for extension, but closed for modification.
  • 4. Liskov substitution principle Every subclass/derived class should be substitutable for their base/parent class. Interface segregation principle A class should never be forced to implement an interface that it doesn't use and a class should never be forced to implement methods that it doesn't use.
  • 5. Dependency inversion principle Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.
  • 7. MVC - MVVM - MVP Design patterns or software architectures?
  • 8. Design pattern A design pattern is the re-usable form of a solution to a design problem. (Singleton - Observer - MVC - MVVM - MVP) Software architecture Software architecture refers to the high level structures of a software system and the discipline of creating such structures and systems. (Hexagonal architecture - Onion architecture - The Clean architecture)
  • 10. Successful Software Architecture Characteristics • Testable • Independent of the UI • Independent of the Database • Independent of Frameworks and External Entities
  • 11. Testable The business logic layer(s) can be tested without the UI, database, net Independent of the UI The UI can be easily modified, without changing the rest of the applica
  • 12. Independent of the Database You can swap out Core Data or SQLite, for Realm, Firebase or something else entirely. Your business logic is not bound to the database or persistence layer(s). Independent of External Entities The architecture does not depend on external libraries. This allows the team to use them as tools, rather than having to adapt your application(s) to their limited constraints and rigid conventions.
  • 14. To make your code:
  • 16.
  • 17. Entities are enterprise-wide business rules that encapsulate the most general business rules, these rules are the least likely to change. Use cases are also called interactors and stand for application-specific business rules of the software. This layer is isolated from changes to the database, common frameworks, and the UI. Interface adapters convert data from a convenient format for entities and use cases to a format applicable to databases and the web, for example. This layer includes Presenters from MVP, ViewModel from MVVM, and Gateways (also known as Repositories). Frameworks and drivers are the outermost layer, which consists of the web framework, database, UI, HTTP client, and so on.
  • 18.
  • 19. - Interactor (Use Case): Contains application specific business rules. - Entity: Contains application independent business rules. - Boundary<I>: Data comes into interactors through boundary (interface/protocol) which is implemented by the interactor. Data goes out from the interactor to boundaries implemented by other objects. - Delivery Mechanism: Can be Web, Console application, Mobile App UI, etc
  • 20. 1- User clicks a button (on a web form for example). 2- The delivery mechanism (ex: Web) takes whatever data submitted by the user and stick it into a data structure which contains only primitives types (Request Model). 3- The request model passed through the input boundary and since the interactor implements the input boundary, the interactor received that request model.
  • 21. 4- Interactor then uses that request model and controls the dance of the entities (ex: creates the order, modify the customer, etc).
  • 22. 5- And when it’s done with that, it continues to control the dance of the entities but this time in the opposite direction as it gather up all the results to create yet another data structure called (Response Model).
  • 23. 6- The response model is passed back out through the output boundary to the delivery mechanism that implement it and somehow it’s delivered to the user.
  • 24.
  • 25. -Response Model contains data that was created by the interactor as the result of the use case, but this data is not presentable, a date for example would be a date object, and the currency would be a money object. -Presenter is a class or a set of classes whose job is to take the response model and translate it into a view model. For example, it takes the date object from the response model and calls simple data formatter which generates a nice date string that the view model will hold, and takes the currency from the response model and puts the currency symbol in the view model. -View Model contains the data that will be used by the view. For example, If there is a button on the view, the view model has the string that holds the name of that button, and if the button shouldn’t be active, so it should be grey, the view model holds the boolean that indicates the status of the button. If there are menu items in the view, the view model has the names of all the menu items and their order. -View all it can do is grabbing the data from the view model and put it on the screen. It should be so stupid so you don’t have to test it. (You can test it with your eyes).
  • 27. –Robert C. Martin “If something changes a lot, it should be a plug-in. If something doesn’t change very often, it should be plugged into.”
  • 28. What about the database? • The database is a detail, it shouldn’t be the center of your architecture. • The database should be a plug-in to the business rules. • Business rules shouldn’t be written in stored procedures in the database.
  • 29.
  • 30.
  • 32. List contacts use case • List all the contacts from the local database and from the phone database. • Group the contacts by mobile number and remove the duplicates. • Present the filtered contacts in a table view.
  • 33.
  • 35. References: • https://www.youtube.com/watch?v=o_TH-Y78tt4 • https://proandroiddev.com/clean-architecture-data-flow-dependency-rule- 615ffdd79e29 • https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean- architecture.html • https://medium.freecodecamp.org/a-quick-introduction-to-clean-architecture- 990c014448d2 • https://medium.com/@pxpgraphics/clean-architecture-3fe6907e7441 • https://hackernoon.com/golang-clean-archithecture-efd6d7c43047 • https://rubygarage.org/blog/clean-android-architecture

Hinweis der Redaktion

  1. We can use multiple design pattern in a single software, but we cannot use multiple architectures in a single software
  2. Robert C. Marten Known in our field as Uncle Bob American Software Engineer Clean Architecture (Augest 2012) Inventor of SOLID principles Clean Code The Clean Coder Clean Architecture
  3. Dependency Rule
  4. Entities: TopUp products Use Cases: TopUp operation
  5. The blog figure The Clean Architecture Cone Simplified My favorite
  6. Usually interactors talks to several entities, ex: CreateOrderInteractor talks to OrderEntity and CustomerEntity. Has-A vs Is-A
  7. Login Use Case LoginDataStructure
  8. Now the interactors can be tested by giving them the request model and get the response model out from them.
  9. Plug-In Architecture Pattern