SlideShare uma empresa Scribd logo
1 de 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!

Mais conteúdo relacionado

Mais procurados

Clean architecture
Clean architectureClean architecture
Clean architectureandbed
 
Hexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootHexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootMikalai Alimenkou
 
Clean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipClean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipIvan Paulovich
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean ArchitectureFlavius Stef
 
Clean architecture on android
Clean architecture on androidClean architecture on android
Clean architecture on androidBenjamin Cheng
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootKashif Ali Siddiqui
 
Hexagonal architecture: how, why and when
Hexagonal architecture: how, why and whenHexagonal architecture: how, why and when
Hexagonal architecture: how, why and whenXoubaman
 
The Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureThe Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureNicolas Carlo
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in JavaIonut Bilica
 
Solid principles
Solid principlesSolid principles
Solid principlesToan Nguyen
 
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Edureka!
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Steve Pember
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software designMatthias Noback
 

Mais procurados (20)

Clean architecture
Clean architectureClean architecture
Clean architecture
 
Hexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootHexagonal architecture with Spring Boot
Hexagonal architecture with Spring Boot
 
Clean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipClean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software Craftsmanship
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Clean architecture on android
Clean architecture on androidClean architecture on android
Clean architecture on android
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring Boot
 
Hexagonal architecture: how, why and when
Hexagonal architecture: how, why and whenHexagonal architecture: how, why and when
Hexagonal architecture: how, why and when
 
The Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureThe Secrets of Hexagonal Architecture
The Secrets of Hexagonal Architecture
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in Java
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Hexagonal architecture
Hexagonal architectureHexagonal architecture
Hexagonal architecture
 
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software design
 

Semelhante a 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
 

Semelhante a 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
 

Último

%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
+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
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 

Último (20)

%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
+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...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 

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

Notas do Editor

  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