SlideShare uma empresa Scribd logo
1 de 66
Baixar para ler offline
Clean Architecture
Iván Álvarez Frías
Erik Jhordan González Reyes
ivan.alvarez@schibsted.com.mx
@Ivanhoe
github.com/ivanhoe
erik.gonzalez@schibsted.com.mx
@ErikJhordan_Rey
github.com/erikcaffrey
“Clean code always looks like it
was written by someone who
cares”
IOS Smells
/ SCHIBSTED MEDIA GROUP
● God View Controller
● Similar code everywhere
● Coupled Code
● My Code is not testable
● Hacks everywhere
● Architecture based on Inheritance
● A lot External Dependencies
IOS Smells
STUPID
/ SCHIBSTED MEDIA GROUP
STUPID
Singleton Invasion
Tight Coupling
Untestability
Premature Optimization
Indescriptive Naming
Duplication
/ SCHIBSTED MEDIA GROUP
From STUPID to SOLID code
These are principles, not laws!
/ SCHIBSTED MEDIA GROUP
SOLID
/ SCHIBSTED MEDIA GROUP
SOLID
Single Responsibility Principle
Open / Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
“Depend upon abstractions. Do not
depend upon concrete classes”
Architecture
/ SCHIBSTED MEDIA GROUP
Architecture
#By Martin Fowler
“Architecture as a word we use when we want to talk about design but want to puff it up
to make it sound important.”
Clean Architecture
/ SCHIBSTED MEDIA GROUP
Entities
Use Cases
Controllers
Gateways
Presenters
Devices
W
ebUI
DB
External Interfaces
Frameworks and drivers
Interface Adapters
Business Rules
Domain Logic
Dependency Rule
/ SCHIBSTED MEDIA GROUP
Source code dependencies can only point inwards!
Nothing in an inner circle can know anything at all about something in an
outer circle. In particular, the name of something declared in an outer circle
must not be mentioned by the code in the an inner circle. That includes,
functions, classes. variables, or any other named software entity.
Dependency Rule
Entities
/ SCHIBSTED MEDIA GROUP
Entities encapsulate Enterprise wide business rules. An entity can be an
object with methods, or it can be a set of data structures and functions. It
doesn’t matter so long as the entities could be used by many different
applications in the enterprise.
Entities
Use Cases
/ SCHIBSTED MEDIA GROUP
The software in this layer contains application specific business rules. It
encapsulates and implements all of the use cases of the system. These use
cases orchestrate the flow of data to and from the entities, and direct those
entities to use their enterprise wide business rules to achieve the goals of
the use case.
Use Cases
Interface Adapters
/ SCHIBSTED MEDIA GROUP
The software in this layer is a set of adapters that convert data from the
format most convenient for the use cases and entities, to the format most
convenient for some external agency such as the Database or the Web.
Interface Adapters
Frameworks and Drivers
/ SCHIBSTED MEDIA GROUP
The outermost layer is generally composed of frameworks and tools such as
the Database, the Web Framework, etc. Generally you don’t write much
code in this layer other than glue code that communicates to the next circle
inwards.
This layer is where all the details go. The Web is a detail. The database is a
detail. We keep these things on the outside where they can do little harm.
Frameworks and Drivers
IOS Clean architecture
/ SCHIBSTED MEDIA GROUP
VIPER
/ SCHIBSTED MEDIA GROUP
View
PresenterViewController
Use Case
Use Case
Use Case
Domain
Model
Data Source
Implementation
Repository
Repository
Data
Source
Data
Source
Data Source
Implementation
Presentation Layer Domain Layer Data Layer
Presentation Layer
/ SCHIBSTED MEDIA GROUP
/ SCHIBSTED MEDIA GROUP
● MVC
● MVP
● MVVM
UI Design Patterns
Talk Schedule
Model
View
Controller
Model
What to display?
View
How it’s displayed?
Controller
Formatting the model for
display and handling events
like user input.
Talk Schedule
Model
View
Presenter
The MVP pattern allows separate
the presentation layer from the
logic, so that everything about
how the interface works is
separated from how we
represent it on screen.
Ideally the MVP pattern would
achieve that same logic might
have completely different and
interchangeable views.
Model View Presenter
View Presenter Model
User interaction
notify user event request data
Update UI
with entities
delivers
entities
/ SCHIBSTED MEDIA GROUP
https://github.com/erikcaffrey/Swift-ModelViewPresenter
Talk Schedule
Model
View
ViewModel
Is an architectural approach used to
abstract the state and behaviour of a
view, which allows us to separate the
development of the UI from the
business logic.
Model View ViewModel
View ViewModel Model
DataBinding
and
Commands
ViewModel
updates the
model
Send
Notifications
Send
Notifications
/ SCHIBSTED MEDIA GROUP
What Do They have in common?
Allows separate the view from the
business logic and data logic.
/ SCHIBSTED MEDIA GROUP
What pattern Should I use?
/ SCHIBSTED MEDIA GROUP
● These patterns try to solve the same problems
● Both patterns are going to improve code quality and testability.
● Think about these patterns and use the one you understand better.
UI Patterns
Domain Layer
/ SCHIBSTED MEDIA GROUP
● Contains Business Logic
● No Code specific to a framework
● Use Command Pattern (optional)
Domain
/ SCHIBSTED MEDIA GROUP
Command Pattern
Holding all your business logic, its main component is UseCase that gives you an easy way to define your
application use cases and execute them in a background thread.
Data Layer
/ SCHIBSTED MEDIA GROUP
Use a repository to separate the logic that retrieves the data and maps it to
the entity model from the business logic that acts on the model. The
business logic should be agnostic to the type of data that comprises the data
source layer. For example, the data source layer can be a database, a
SharePoint list, or a Web service.
Repository Pattern
/ SCHIBSTED MEDIA GROUP
Data
Mapper
Repository
Client
Business
Logic
Business Entity
Business Entity
Persist
Query
Query
Object
Data Source
/ SCHIBSTED MEDIA GROUP
Software Design Pattern used to facilitate the usage of Dependency
Inversion.
It consists of passing dependencies (inject them) via constructor or setter in
order to extract the task of creating modules out from other modules.
Objects are instantiated somewhere else and passed as constructor
attributes when creating the current object.
Dependency Injection
/ SCHIBSTED MEDIA GROUP
● Since dependencies can be injected and configured externally we can reuse
those components.
● We can just change the implementation of any object without having to
make a lot of changes in our codebase, since that object instantiation resides
in one place isolated and decoupled.
● Dependencies can be injected into a component: it is possible to inject mock
implementations of these dependencies which makes testing easier.
Dependency Injection Advantages
/ SCHIBSTED MEDIA GROUP
● But here it comes a new problem. If we can’t create modules inside modules,
there must be a place where those modules are instantiated.
● Modules with huge constructors including lots of dependencies, code will
become dirty and hard to read.
Dependency Injection Smells
Solution ….
Dependency Injector
/ SCHIBSTED MEDIA GROUP
We can consider it as another module in our app that is in charge of providing
instances of the rest of modules and inject their dependencies.
Dependency Injector
● Service Locator
● Swinject
● Typhoon
/ SCHIBSTED MEDIA GROUP
Clean Architecture Principles
● The Dependency Rule
● Presentation is decoupled from domain
● Domain module can be a layer module.
● Data layer decouples the rest of the app
● Independent of Frameworks.
● Independent of UI
● Independent of Database
● Entities Representing Enterprise Rules
/ SCHIBSTED MEDIA GROUP
Conforming to these simple rules is not hard, and will save you a lot of
headaches going forward. By separating the software into layers, and
conforming to The Dependency Rule, you will create a system that is intrinsically
testable, with all the benefits that implies. When any of the external parts of the
system become obsolete, like the database, or the web framework, you can
replace those obsolete elements with a minimum of fuss.
Clean Architecture Conclusion
#Uncle Bob
Routing
/ SCHIBSTED MEDIA GROUP
Routing
● Segues
● TabBarViewController
● NavigationViewController
● Push
● Search
Solution
● Navigator
● Wireframe
Show me code!
/ SCHIBSTED MEDIA GROUP
/ SCHIBSTED MEDIA GROUP
/ SCHIBSTED MEDIA GROUP
● Depend on abstractions do not depend on concrete class
● Use design patterns on smart way
● Avoid coupled code and strive for loosely coupled design between
objects that interact
● Avoid expensive tasks executed on main thread
● Maintain a clean code style
● Write Clean and Solid Code
● Favor composition over inheritance
● If your code is coupled the Refactor is your friend
● Write test is your responsibility
Advices
01
02
https://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html
Uncle Bob - Clean Architecture
https://www.youtube.com/watch?v=WpkDN78P884
Uncle Bob - Architecture the lost years
03
Further Reading
04
https://speakerdeck.com/karumi/architecting-your-apps-for-ui-testing
Alberto Gragera - Architecting your apps for UI Testing
https://erikcaffrey.github.io/ANDROID-clean-architecture/
Erik Jhordan Rey - Clean Architecture
Questions?
Find me
Erik Jhordan González Reyes
Mobile Engineer
github.com/erikcaffrey
erik.gonzalez@schibsted.com.mx
erikcaffrey.github.io
@ErikJhordan_Rey
+Erik Jhordan Rey
Find me
Iván Álvarez Frías
Software Engineer
github.com/ivanhoe
ivan.alvarez@schibsted.com.mx
iosdevelopers.mx
@Ivanhoe
+Ivan ??
Thank You
{NS Coder México}!

Mais conteúdo relacionado

Mais procurados

SOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureSOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureMohamed Galal
 
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
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean ArchitectureMattia Battiston
 
DDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichDDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichIvan Paulovich
 
Clean architecture - Protecting the Domain
Clean architecture - Protecting the DomainClean architecture - Protecting the Domain
Clean architecture - Protecting the DomainVictor Rentea
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven DesignAndriy Buday
 
Solid principles
Solid principlesSolid principles
Solid principlesToan Nguyen
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)Tom Kocjan
 
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
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsAraf Karsh Hamid
 
Domain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationDomain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationOğuzhan Soykan
 
Hexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootHexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootMikalai Alimenkou
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applicationsFabricio Epaminondas
 
OutSystems Tips and Tricks
OutSystems Tips and TricksOutSystems Tips and Tricks
OutSystems Tips and TricksOutSystems
 
Hexagonal Architecture
Hexagonal ArchitectureHexagonal Architecture
Hexagonal ArchitectureMarcelo Cure
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patternsallanh0526
 

Mais procurados (20)

SOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureSOLID Principles and The Clean Architecture
SOLID Principles and The Clean Architecture
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 
Architecture: Microservices
Architecture: MicroservicesArchitecture: Microservices
Architecture: Microservices
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
 
DDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichDDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan Paulovich
 
Clean architecture - Protecting the Domain
Clean architecture - Protecting the DomainClean architecture - Protecting the Domain
Clean architecture - Protecting the Domain
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
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
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Domain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationDomain Driven Design(DDD) Presentation
Domain Driven Design(DDD) Presentation
 
Hexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootHexagonal architecture with Spring Boot
Hexagonal architecture with Spring Boot
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
 
OutSystems Tips and Tricks
OutSystems Tips and TricksOutSystems Tips and Tricks
OutSystems Tips and Tricks
 
Hexagonal Architecture
Hexagonal ArchitectureHexagonal Architecture
Hexagonal Architecture
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
 

Destaque

Taming the Massive View Controllers
Taming the Massive View ControllersTaming the Massive View Controllers
Taming the Massive View ControllersNSCoder Mexico
 
iOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editioniOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editionJorge Ortiz
 
Introduction to VIPER Architecture
Introduction to VIPER ArchitectureIntroduction to VIPER Architecture
Introduction to VIPER ArchitectureHendy Christianto
 
Writing Clean Code in Swift
Writing Clean Code in SwiftWriting Clean Code in Swift
Writing Clean Code in SwiftDerek Lee Boire
 
iOS viper presentation
iOS viper presentationiOS viper presentation
iOS viper presentationRajat Datta
 
OpenID Connect: The new standard for connecting to your Customers, Partners, ...
OpenID Connect: The new standard for connecting to your Customers, Partners, ...OpenID Connect: The new standard for connecting to your Customers, Partners, ...
OpenID Connect: The new standard for connecting to your Customers, Partners, ...Salesforce Developers
 
OAuth based reference architecture for API Management
OAuth based reference architecture for API ManagementOAuth based reference architecture for API Management
OAuth based reference architecture for API ManagementWSO2
 
Modernize Service-Oriented Architecture with APIs
Modernize Service-Oriented Architecture with APIsModernize Service-Oriented Architecture with APIs
Modernize Service-Oriented Architecture with APIsApigee | Google Cloud
 
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSSoftware architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSJinkyu Kim
 
ITANA 2016: API Architecture and Implementation
ITANA 2016: API Architecture and ImplementationITANA 2016: API Architecture and Implementation
ITANA 2016: API Architecture and ImplementationColin Bell
 
Modernizing an Existing SOA-based Architecture with APIs
Modernizing an Existing SOA-based Architecture with APIsModernizing an Existing SOA-based Architecture with APIs
Modernizing an Existing SOA-based Architecture with APIsApigee | Google Cloud
 
Success with APIs: A Checklist
Success with APIs: A ChecklistSuccess with APIs: A Checklist
Success with APIs: A ChecklistCA Technologies
 
OpenID Connect: An Overview
OpenID Connect: An OverviewOpenID Connect: An Overview
OpenID Connect: An OverviewPat Patterson
 
Android Clean Architecture for Dummies
Android Clean Architecture for DummiesAndroid Clean Architecture for Dummies
Android Clean Architecture for DummiesKengo Suzuki
 
OpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersOpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersSalesforce Developers
 
Lightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and DesignLightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and DesignDeivison Sporteman
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API PlatformJohannes Ridderstedt
 

Destaque (20)

Taming the Massive View Controllers
Taming the Massive View ControllersTaming the Massive View Controllers
Taming the Massive View Controllers
 
iOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editioniOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h edition
 
Introduction to VIPER Architecture
Introduction to VIPER ArchitectureIntroduction to VIPER Architecture
Introduction to VIPER Architecture
 
Writing Clean Code in Swift
Writing Clean Code in SwiftWriting Clean Code in Swift
Writing Clean Code in Swift
 
API Governance
API Governance API Governance
API Governance
 
iOS viper presentation
iOS viper presentationiOS viper presentation
iOS viper presentation
 
AE Foyer: Soa Integration Architecture and Api Management
AE Foyer: Soa Integration Architecture and Api ManagementAE Foyer: Soa Integration Architecture and Api Management
AE Foyer: Soa Integration Architecture and Api Management
 
OpenID Connect: The new standard for connecting to your Customers, Partners, ...
OpenID Connect: The new standard for connecting to your Customers, Partners, ...OpenID Connect: The new standard for connecting to your Customers, Partners, ...
OpenID Connect: The new standard for connecting to your Customers, Partners, ...
 
OAuth based reference architecture for API Management
OAuth based reference architecture for API ManagementOAuth based reference architecture for API Management
OAuth based reference architecture for API Management
 
Modernize Service-Oriented Architecture with APIs
Modernize Service-Oriented Architecture with APIsModernize Service-Oriented Architecture with APIs
Modernize Service-Oriented Architecture with APIs
 
OpenID Connect Explained
OpenID Connect ExplainedOpenID Connect Explained
OpenID Connect Explained
 
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSSoftware architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
 
ITANA 2016: API Architecture and Implementation
ITANA 2016: API Architecture and ImplementationITANA 2016: API Architecture and Implementation
ITANA 2016: API Architecture and Implementation
 
Modernizing an Existing SOA-based Architecture with APIs
Modernizing an Existing SOA-based Architecture with APIsModernizing an Existing SOA-based Architecture with APIs
Modernizing an Existing SOA-based Architecture with APIs
 
Success with APIs: A Checklist
Success with APIs: A ChecklistSuccess with APIs: A Checklist
Success with APIs: A Checklist
 
OpenID Connect: An Overview
OpenID Connect: An OverviewOpenID Connect: An Overview
OpenID Connect: An Overview
 
Android Clean Architecture for Dummies
Android Clean Architecture for DummiesAndroid Clean Architecture for Dummies
Android Clean Architecture for Dummies
 
OpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersOpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for Beginners
 
Lightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and DesignLightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and Design
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API Platform
 

Semelhante a Clean Architecture

The Clean Architecture
The Clean ArchitectureThe Clean Architecture
The Clean ArchitectureDmytro Turskyi
 
Revolution in integration!
Revolution in integration!Revolution in integration!
Revolution in integration!Gregor Vogrin
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsJuan Lopez
 
Git & dev ops come together, right now!
Git & dev ops come together, right now!Git & dev ops come together, right now!
Git & dev ops come together, right now!rhirschfeld
 
Microservices - Yet another buzzword
Microservices - Yet another buzzwordMicroservices - Yet another buzzword
Microservices - Yet another buzzwordOvidiu Dimulescu
 
Software Architecture for Agile Development
Software Architecture for Agile DevelopmentSoftware Architecture for Agile Development
Software Architecture for Agile DevelopmentHayim Makabee
 
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...Sabino Labarile
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast trackBinu Bhasuran
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVMBoulos Dib
 
[Android] DI in multimodule application
[Android] DI in multimodule application[Android] DI in multimodule application
[Android] DI in multimodule applicationOleg Mazhukin
 
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"GlobalLogic Ukraine
 
Александр Белецкий "Архитектура Javascript приложений"
 Александр Белецкий "Архитектура Javascript приложений" Александр Белецкий "Архитектура Javascript приложений"
Александр Белецкий "Архитектура Javascript приложений"Agile Base Camp
 
Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Manoj Ellappan
 
Pragmatic Approach to Microservices and Cell-based Architecture
Pragmatic Approach to Microservices and Cell-based Architecture Pragmatic Approach to Microservices and Cell-based Architecture
Pragmatic Approach to Microservices and Cell-based Architecture Andrew Blades
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Luis Valencia
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCUlrich Krause
 

Semelhante a Clean Architecture (20)

The Clean Architecture
The Clean ArchitectureThe Clean Architecture
The Clean Architecture
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Revolution in integration!
Revolution in integration!Revolution in integration!
Revolution in integration!
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and Patterns
 
Git & dev ops come together, right now!
Git & dev ops come together, right now!Git & dev ops come together, right now!
Git & dev ops come together, right now!
 
Microservices - Yet another buzzword
Microservices - Yet another buzzwordMicroservices - Yet another buzzword
Microservices - Yet another buzzword
 
Going Headless (JAMStack Berlin 2019)
Going Headless (JAMStack Berlin 2019)Going Headless (JAMStack Berlin 2019)
Going Headless (JAMStack Berlin 2019)
 
Software Architecture for Agile Development
Software Architecture for Agile DevelopmentSoftware Architecture for Agile Development
Software Architecture for Agile Development
 
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast track
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
 
[Android] DI in multimodule application
[Android] DI in multimodule application[Android] DI in multimodule application
[Android] DI in multimodule application
 
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
 
Александр Белецкий "Архитектура Javascript приложений"
 Александр Белецкий "Архитектура Javascript приложений" Александр Белецкий "Архитектура Javascript приложений"
Александр Белецкий "Архитектура Javascript приложений"
 
Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1
 
Pragmatic Approach to Microservices and Cell-based Architecture
Pragmatic Approach to Microservices and Cell-based Architecture Pragmatic Approach to Microservices and Cell-based Architecture
Pragmatic Approach to Microservices and Cell-based Architecture
 
L02 Architecture
L02 ArchitectureL02 Architecture
L02 Architecture
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
06 fse design
06 fse design06 fse design
06 fse design
 

Mais de NSCoder Mexico

Aprendizaje reforzado con swift
Aprendizaje reforzado con swiftAprendizaje reforzado con swift
Aprendizaje reforzado con swiftNSCoder Mexico
 
Programación Orientada a Protocolos
Programación Orientada a ProtocolosProgramación Orientada a Protocolos
Programación Orientada a ProtocolosNSCoder Mexico
 
Interfaces en interface builder y por codigo
Interfaces en interface builder y por codigoInterfaces en interface builder y por codigo
Interfaces en interface builder y por codigoNSCoder Mexico
 
Core ML and Computer Vision
Core ML and Computer VisionCore ML and Computer Vision
Core ML and Computer VisionNSCoder Mexico
 
Intro programacion funcional
Intro programacion funcionalIntro programacion funcional
Intro programacion funcionalNSCoder Mexico
 
Mathematics en la programación
Mathematics en la programaciónMathematics en la programación
Mathematics en la programaciónNSCoder Mexico
 
Video juegos con SpriteKit y Swift
Video juegos con SpriteKit y SwiftVideo juegos con SpriteKit y Swift
Video juegos con SpriteKit y SwiftNSCoder Mexico
 
Introduction a ARToolkit
Introduction a ARToolkitIntroduction a ARToolkit
Introduction a ARToolkitNSCoder Mexico
 
Diseño Agil para Desarrolladores
Diseño Agil para DesarrolladoresDiseño Agil para Desarrolladores
Diseño Agil para DesarrolladoresNSCoder Mexico
 
Simplify your Life with Message Extensions in iOS 10
Simplify your Life with Message Extensions in iOS 10Simplify your Life with Message Extensions in iOS 10
Simplify your Life with Message Extensions in iOS 10NSCoder Mexico
 

Mais de NSCoder Mexico (20)

Aprendizaje reforzado con swift
Aprendizaje reforzado con swiftAprendizaje reforzado con swift
Aprendizaje reforzado con swift
 
In app purchase
In app purchaseIn app purchase
In app purchase
 
Ib designables
Ib designablesIb designables
Ib designables
 
Programación Orientada a Protocolos
Programación Orientada a ProtocolosProgramación Orientada a Protocolos
Programación Orientada a Protocolos
 
Interfaces en interface builder y por codigo
Interfaces en interface builder y por codigoInterfaces en interface builder y por codigo
Interfaces en interface builder y por codigo
 
Introduction Swift
Introduction SwiftIntroduction Swift
Introduction Swift
 
Dependency Managers
Dependency ManagersDependency Managers
Dependency Managers
 
Taller PaintCode
Taller PaintCodeTaller PaintCode
Taller PaintCode
 
VIPER
VIPERVIPER
VIPER
 
Core ML and Computer Vision
Core ML and Computer VisionCore ML and Computer Vision
Core ML and Computer Vision
 
Intro programacion funcional
Intro programacion funcionalIntro programacion funcional
Intro programacion funcional
 
DIY Instagram
DIY InstagramDIY Instagram
DIY Instagram
 
Mathematics en la programación
Mathematics en la programaciónMathematics en la programación
Mathematics en la programación
 
Video juegos con SpriteKit y Swift
Video juegos con SpriteKit y SwiftVideo juegos con SpriteKit y Swift
Video juegos con SpriteKit y Swift
 
Unit Testing en iOS
Unit Testing en iOSUnit Testing en iOS
Unit Testing en iOS
 
Bridgefy SDK
Bridgefy SDKBridgefy SDK
Bridgefy SDK
 
Introduction a ARToolkit
Introduction a ARToolkitIntroduction a ARToolkit
Introduction a ARToolkit
 
Diseño Agil para Desarrolladores
Diseño Agil para DesarrolladoresDiseño Agil para Desarrolladores
Diseño Agil para Desarrolladores
 
Simplify your Life with Message Extensions in iOS 10
Simplify your Life with Message Extensions in iOS 10Simplify your Life with Message Extensions in iOS 10
Simplify your Life with Message Extensions in iOS 10
 
Apple Watch
Apple WatchApple Watch
Apple Watch
 

Último

%+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
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%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
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...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
 
+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
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%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
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 

Último (20)

%+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...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%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
 
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
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+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...
 
+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...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%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
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 

Clean Architecture

  • 1. Clean Architecture Iván Álvarez Frías Erik Jhordan González Reyes ivan.alvarez@schibsted.com.mx @Ivanhoe github.com/ivanhoe erik.gonzalez@schibsted.com.mx @ErikJhordan_Rey github.com/erikcaffrey
  • 2. “Clean code always looks like it was written by someone who cares”
  • 4. / SCHIBSTED MEDIA GROUP ● God View Controller ● Similar code everywhere ● Coupled Code ● My Code is not testable ● Hacks everywhere ● Architecture based on Inheritance ● A lot External Dependencies IOS Smells
  • 6. / SCHIBSTED MEDIA GROUP STUPID Singleton Invasion Tight Coupling Untestability Premature Optimization Indescriptive Naming Duplication
  • 7. / SCHIBSTED MEDIA GROUP From STUPID to SOLID code These are principles, not laws!
  • 10. / SCHIBSTED MEDIA GROUP SOLID Single Responsibility Principle Open / Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle
  • 11. “Depend upon abstractions. Do not depend upon concrete classes”
  • 13. / SCHIBSTED MEDIA GROUP Architecture #By Martin Fowler “Architecture as a word we use when we want to talk about design but want to puff it up to make it sound important.”
  • 15. / SCHIBSTED MEDIA GROUP Entities Use Cases Controllers Gateways Presenters Devices W ebUI DB External Interfaces Frameworks and drivers Interface Adapters Business Rules Domain Logic
  • 17. / SCHIBSTED MEDIA GROUP Source code dependencies can only point inwards! Nothing in an inner circle can know anything at all about something in an outer circle. In particular, the name of something declared in an outer circle must not be mentioned by the code in the an inner circle. That includes, functions, classes. variables, or any other named software entity. Dependency Rule
  • 19. / SCHIBSTED MEDIA GROUP Entities encapsulate Enterprise wide business rules. An entity can be an object with methods, or it can be a set of data structures and functions. It doesn’t matter so long as the entities could be used by many different applications in the enterprise. Entities
  • 21. / SCHIBSTED MEDIA GROUP The software in this layer contains application specific business rules. It encapsulates and implements all of the use cases of the system. These use cases orchestrate the flow of data to and from the entities, and direct those entities to use their enterprise wide business rules to achieve the goals of the use case. Use Cases
  • 23. / SCHIBSTED MEDIA GROUP The software in this layer is a set of adapters that convert data from the format most convenient for the use cases and entities, to the format most convenient for some external agency such as the Database or the Web. Interface Adapters
  • 25. / SCHIBSTED MEDIA GROUP The outermost layer is generally composed of frameworks and tools such as the Database, the Web Framework, etc. Generally you don’t write much code in this layer other than glue code that communicates to the next circle inwards. This layer is where all the details go. The Web is a detail. The database is a detail. We keep these things on the outside where they can do little harm. Frameworks and Drivers
  • 27. / SCHIBSTED MEDIA GROUP VIPER
  • 28. / SCHIBSTED MEDIA GROUP View PresenterViewController Use Case Use Case Use Case Domain Model Data Source Implementation Repository Repository Data Source Data Source Data Source Implementation Presentation Layer Domain Layer Data Layer
  • 31. / SCHIBSTED MEDIA GROUP ● MVC ● MVP ● MVVM UI Design Patterns
  • 32. Talk Schedule Model View Controller Model What to display? View How it’s displayed? Controller Formatting the model for display and handling events like user input.
  • 33. Talk Schedule Model View Presenter The MVP pattern allows separate the presentation layer from the logic, so that everything about how the interface works is separated from how we represent it on screen. Ideally the MVP pattern would achieve that same logic might have completely different and interchangeable views.
  • 34. Model View Presenter View Presenter Model User interaction notify user event request data Update UI with entities delivers entities
  • 35. / SCHIBSTED MEDIA GROUP https://github.com/erikcaffrey/Swift-ModelViewPresenter
  • 36. Talk Schedule Model View ViewModel Is an architectural approach used to abstract the state and behaviour of a view, which allows us to separate the development of the UI from the business logic.
  • 37. Model View ViewModel View ViewModel Model DataBinding and Commands ViewModel updates the model Send Notifications Send Notifications
  • 38. / SCHIBSTED MEDIA GROUP What Do They have in common?
  • 39. Allows separate the view from the business logic and data logic.
  • 40. / SCHIBSTED MEDIA GROUP What pattern Should I use?
  • 41. / SCHIBSTED MEDIA GROUP ● These patterns try to solve the same problems ● Both patterns are going to improve code quality and testability. ● Think about these patterns and use the one you understand better. UI Patterns
  • 43. / SCHIBSTED MEDIA GROUP ● Contains Business Logic ● No Code specific to a framework ● Use Command Pattern (optional) Domain
  • 44. / SCHIBSTED MEDIA GROUP Command Pattern Holding all your business logic, its main component is UseCase that gives you an easy way to define your application use cases and execute them in a background thread.
  • 46. / SCHIBSTED MEDIA GROUP Use a repository to separate the logic that retrieves the data and maps it to the entity model from the business logic that acts on the model. The business logic should be agnostic to the type of data that comprises the data source layer. For example, the data source layer can be a database, a SharePoint list, or a Web service. Repository Pattern
  • 47. / SCHIBSTED MEDIA GROUP Data Mapper Repository Client Business Logic Business Entity Business Entity Persist Query Query Object Data Source
  • 48. / SCHIBSTED MEDIA GROUP Software Design Pattern used to facilitate the usage of Dependency Inversion. It consists of passing dependencies (inject them) via constructor or setter in order to extract the task of creating modules out from other modules. Objects are instantiated somewhere else and passed as constructor attributes when creating the current object. Dependency Injection
  • 49. / SCHIBSTED MEDIA GROUP ● Since dependencies can be injected and configured externally we can reuse those components. ● We can just change the implementation of any object without having to make a lot of changes in our codebase, since that object instantiation resides in one place isolated and decoupled. ● Dependencies can be injected into a component: it is possible to inject mock implementations of these dependencies which makes testing easier. Dependency Injection Advantages
  • 50. / SCHIBSTED MEDIA GROUP ● But here it comes a new problem. If we can’t create modules inside modules, there must be a place where those modules are instantiated. ● Modules with huge constructors including lots of dependencies, code will become dirty and hard to read. Dependency Injection Smells
  • 53. / SCHIBSTED MEDIA GROUP We can consider it as another module in our app that is in charge of providing instances of the rest of modules and inject their dependencies. Dependency Injector ● Service Locator ● Swinject ● Typhoon
  • 54. / SCHIBSTED MEDIA GROUP Clean Architecture Principles ● The Dependency Rule ● Presentation is decoupled from domain ● Domain module can be a layer module. ● Data layer decouples the rest of the app ● Independent of Frameworks. ● Independent of UI ● Independent of Database ● Entities Representing Enterprise Rules
  • 55. / SCHIBSTED MEDIA GROUP Conforming to these simple rules is not hard, and will save you a lot of headaches going forward. By separating the software into layers, and conforming to The Dependency Rule, you will create a system that is intrinsically testable, with all the benefits that implies. When any of the external parts of the system become obsolete, like the database, or the web framework, you can replace those obsolete elements with a minimum of fuss. Clean Architecture Conclusion #Uncle Bob
  • 57. / SCHIBSTED MEDIA GROUP Routing ● Segues ● TabBarViewController ● NavigationViewController ● Push ● Search Solution ● Navigator ● Wireframe
  • 62. ● Depend on abstractions do not depend on concrete class ● Use design patterns on smart way ● Avoid coupled code and strive for loosely coupled design between objects that interact ● Avoid expensive tasks executed on main thread ● Maintain a clean code style ● Write Clean and Solid Code ● Favor composition over inheritance ● If your code is coupled the Refactor is your friend ● Write test is your responsibility Advices
  • 63. 01 02 https://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html Uncle Bob - Clean Architecture https://www.youtube.com/watch?v=WpkDN78P884 Uncle Bob - Architecture the lost years 03 Further Reading 04 https://speakerdeck.com/karumi/architecting-your-apps-for-ui-testing Alberto Gragera - Architecting your apps for UI Testing https://erikcaffrey.github.io/ANDROID-clean-architecture/ Erik Jhordan Rey - Clean Architecture
  • 65. Find me Erik Jhordan González Reyes Mobile Engineer github.com/erikcaffrey erik.gonzalez@schibsted.com.mx erikcaffrey.github.io @ErikJhordan_Rey +Erik Jhordan Rey Find me Iván Álvarez Frías Software Engineer github.com/ivanhoe ivan.alvarez@schibsted.com.mx iosdevelopers.mx @Ivanhoe +Ivan ??
  • 66. Thank You {NS Coder México}!