SlideShare a Scribd company logo
VIPER Architecture
By: Ahmed Lotfy
VIPER Overview
VIPER Architecture approach
for application development
Clean Architecture divides
logical structure into distinct
layers of responsibility.
VIPER Main Goals
Resolve problems. Increase of test coverage for
the Presentation level.
Using Single Responsibility Principle
History
●08 - 2012
⚪An article The Clean Architecture by Robert Martin.
●12 - 2013
⚪An article Introduction to VIPER
●06 - 2014
⚪Issue #13. objc.io Architecting iOS Apps with VIPER
●New architecture, introduced on 2014
at Mutual Mobile.
History
“We found that writing tests for iOS apps was difficult.
We decided that if we were going to improve the way we
test our software, we would first need to come up with a
better way to architect our apps. We call that method
VIPER”.
Note
“VIPER is not the list of rules and templates. It's
the list of recommendations how to build flexible,
testable and reusable architecture.”
What is the problem?
Old Paradigm
My project is getting larger..
Best Architecture?
Big Project
Massive View Controller
●What goes into View Controllers?
Application Flows
Transitions
Massive View Controller
Large files (+1000 lines) High complexity Unstructured code
Maybe VIPER Will Solve The Problem
VIPER Architecture
VIPER Components
V(iew) I(nteractor) P(resenter) E(ntity) R(outer)
VIPER Components
Components
act like plugins
to use cases.
VIPER is a way of describing:
○ What is the role of each of these
components?
○ How they can interact with one
another?
Entity
Contains basic model objects.
Don’t be surprised if your entities are just data
structures.
Entities are only manipulated by the Interactor.
Example
Interactor
A single use case.
Business logic to Entities to a specific task.
Should be independent of any UI.
The Interactor never passes entities to the presentation
layer.
Interactor
The same Interactor could be
used in an iOS app or an OS X
app.
Easy to develop using TDD.
Data Manage
Data Manager Role:
⚪ Building fetch requests.
⚪ Store/fetch data from
database.
This allows the Interactor to
focus more on application logic
and not have to know anything
about how. Entities are
gathered or persisted.
Interactor Example
Example
View
Passive Component (UILabel, UITableView, ..).
Determine how the content is displayed.
The Presenter give it contents to display.
It never asks the Presenter for data.
Wireframes (Routing)
Own the UINavigationController and UIViewController
Create a View/ViewController and installing it in the
window.
Contain navigation logic for describing which screens are
shown in which order.
Routes from one screen to another are defined here.
Example
Presenter
●Contain view logic.
●Do not know about UILabel, UIButton, etc.
●Know about the content and when it should be displayed.
Presenter
Contain the logic to react to user inputs by requesting
new data from the Interactor.
Receive results from an Interactor and Prepare content
to a form that is efficient to update the UI.
Entities are never passed.
Simple data structures passed.
Use the wireframe to perform the navigation and
present the UI.
Example
Example
Presenter and View
The communicate between Presenter and View by a
higher level of abstraction (a protocol) expressed in
terms of its content,
and not how that content is to be displayed.
Presenter and Wireframe
●The Presenter knows:
⚪When to navigate to another screen.
⚪Which screen to navigate to it.
●The wireframe knows:
⚪How to navigate.
⚪Handle navigation transition animations.
Presenter and Wireframe
Responsibility for Routing is shared between two
objects: the Presenter, and the wireframe.
Together, they describe a route from one screen to the
next.
Example
VIPER and Storyboard
VIPER tends not to use segues.
The danger with segues is they make it very difficult to
keep the separation between UI and application logic –
intact.
Using VIPER to Build Modules
A screen or set of screens tends to come together as a
module.
A module can be described as a feature.
Good simple way to organize code.
Easy to find a class exactly where you
expected to look for it.
Designing your App as a set of Modules
Modules can have very clear and well-defined
interfaces, as well as be independent of other
modules.
This makes it much easier to add/remove features, or to
change the way the interface presents various modules
to the user.
Modules
A module might include a common application logic
layer of entities, interactors, and managers that can
be used for multiple screens.
Depends on the interaction between these screens and
how similar they are.
A module could just as easily represent only a single
screen.
Testing with VIPER
Separation of concerns makes it
easier to adopt TDD.
The Interactor contains pure logic.
The Presenter contains logic to
prepare data for display.
They are independent of any UI
Generarted Tools
iOS Code generation:
Generamba ViperCode
VIPER gen
Boa
VIPER vs. MV(C/P)
Advantages
Structure:
Lighter and Neat Code!
Stricter classes.
Isolate dependencies.
Separated concerns.
Conforms to “Single Responsibility Principle”.
Advantages
Help Team:
Helps developer to be more explicit about separation of
code.
Excellent scalability of the tasks among developers.
●Easier to maintain.
Test:
Easier to test the interactions at the boundaries
between layers (No excuse for making tests).
Advantages
Test:
Increase of testability for the application presentation
layer.
Modules are independent from each other. It makes the
separate development environment and increases the
code reusability.
Main architecture approaches are defined. So it's much
easier to add new developer into the team or move
project to another team.
Disadvantages
VIPER looks difficult at first, especially for
developers without the team work
experiences on large projects.
Highly increases of the number of class in the
project, as well as the complexity of
creating the new module.
Some principles don't work with UIKit out of
the box (Segue).
References
https://www.objc.io/issues/13-architecture/viper/
Swift example.
https://github.com/rambler-digital-solutions/The-Book-
of-VIPER/blob/master/english/introduction-to-
viper.md
http://www.slideshare.net/instinctools_EE_Labs/viper-
architecture-59871979
http://www.slideshare.net/HendyChristianto/introducti
on-to-viper-architecture
References
#8 VIPER to be or not to be?
https://brigade.engineering/brigades-experience-using-
an-mvc-alternative-36ef1601a41f#.a0skcve7l
https://github.com/rambler-digital-solutions/The-Book-
of-VIPER/blob/master/english/contents.md
https://8thlight.com/blog/uncle-bob/2012/08/13/the-
clean-architecture.html
Android Templates.
Thank you

More Related Content

What's hot

Property wrapper and how to use them with mvvm in swift ui i copy
Property wrapper and how to use them with mvvm in swift ui i copyProperty wrapper and how to use them with mvvm in swift ui i copy
Property wrapper and how to use them with mvvm in swift ui i copyWannitaTolaema
 
Microservices Tutorial for Beginners | Microservices Architecture | Microserv...
Microservices Tutorial for Beginners | Microservices Architecture | Microserv...Microservices Tutorial for Beginners | Microservices Architecture | Microserv...
Microservices Tutorial for Beginners | Microservices Architecture | Microserv...
Edureka!
 
SOAP REST 이해
SOAP REST 이해SOAP REST 이해
SOAP REST 이해
Jake Yoon
 
Api Gateway
Api GatewayApi Gateway
Api Gateway
KhaqanAshraf
 
API & Backend Integration
API & Backend IntegrationAPI & Backend Integration
API & Backend Integration
Elewayte
 
Docker로 서버 개발 편하게 하기
Docker로 서버 개발 편하게 하기Docker로 서버 개발 편하게 하기
Docker로 서버 개발 편하게 하기
Dronix
 
Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker, Inc.
 
Introduction to Nexus Repository Manager.pdf
Introduction to Nexus Repository Manager.pdfIntroduction to Nexus Repository Manager.pdf
Introduction to Nexus Repository Manager.pdf
Knoldus Inc.
 
Service Oriented Architecture
Service Oriented ArchitectureService Oriented Architecture
Service Oriented ArchitectureLuqman Shareef
 
SOA Service Oriented Architecture
SOA Service Oriented ArchitectureSOA Service Oriented Architecture
SOA Service Oriented Architecture
Vinay Rajadhyaksha
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
Prem Sanil
 
Effective API Gateway
Effective API GatewayEffective API Gateway
Effective API Gateway
Hari Wiz
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
allanh0526
 
API Management Solution Powerpoint Presentation Slides
API Management Solution Powerpoint Presentation SlidesAPI Management Solution Powerpoint Presentation Slides
API Management Solution Powerpoint Presentation Slides
SlideTeam
 
WSO2 API Manager 2.0 - Overview
WSO2 API Manager 2.0 - Overview WSO2 API Manager 2.0 - Overview
WSO2 API Manager 2.0 - Overview
Edgar Silva
 
Why Microservice
Why Microservice Why Microservice
Why Microservice
Kelvin Yeung
 
Azure Bot Service
Azure Bot ServiceAzure Bot Service
Azure Bot Service
Azure Riyadh User Group
 
VIPER - Design Pattern
VIPER - Design PatternVIPER - Design Pattern
VIPER - Design Pattern
Pedro Henrique Peralta
 
What is an API Gateway?
What is an API Gateway?What is an API Gateway?
What is an API Gateway?
LunchBadger
 

What's hot (20)

Property wrapper and how to use them with mvvm in swift ui i copy
Property wrapper and how to use them with mvvm in swift ui i copyProperty wrapper and how to use them with mvvm in swift ui i copy
Property wrapper and how to use them with mvvm in swift ui i copy
 
Microservices Tutorial for Beginners | Microservices Architecture | Microserv...
Microservices Tutorial for Beginners | Microservices Architecture | Microserv...Microservices Tutorial for Beginners | Microservices Architecture | Microserv...
Microservices Tutorial for Beginners | Microservices Architecture | Microserv...
 
SOAP REST 이해
SOAP REST 이해SOAP REST 이해
SOAP REST 이해
 
Api Gateway
Api GatewayApi Gateway
Api Gateway
 
API & Backend Integration
API & Backend IntegrationAPI & Backend Integration
API & Backend Integration
 
Docker로 서버 개발 편하게 하기
Docker로 서버 개발 편하게 하기Docker로 서버 개발 편하게 하기
Docker로 서버 개발 편하게 하기
 
Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to Docker
 
Introduction to Nexus Repository Manager.pdf
Introduction to Nexus Repository Manager.pdfIntroduction to Nexus Repository Manager.pdf
Introduction to Nexus Repository Manager.pdf
 
Service Oriented Architecture
Service Oriented ArchitectureService Oriented Architecture
Service Oriented Architecture
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
SOA Service Oriented Architecture
SOA Service Oriented ArchitectureSOA Service Oriented Architecture
SOA Service Oriented Architecture
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
Effective API Gateway
Effective API GatewayEffective API Gateway
Effective API Gateway
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
 
API Management Solution Powerpoint Presentation Slides
API Management Solution Powerpoint Presentation SlidesAPI Management Solution Powerpoint Presentation Slides
API Management Solution Powerpoint Presentation Slides
 
WSO2 API Manager 2.0 - Overview
WSO2 API Manager 2.0 - Overview WSO2 API Manager 2.0 - Overview
WSO2 API Manager 2.0 - Overview
 
Why Microservice
Why Microservice Why Microservice
Why Microservice
 
Azure Bot Service
Azure Bot ServiceAzure Bot Service
Azure Bot Service
 
VIPER - Design Pattern
VIPER - Design PatternVIPER - Design Pattern
VIPER - Design Pattern
 
What is an API Gateway?
What is an API Gateway?What is an API Gateway?
What is an API Gateway?
 

Similar to VIPER Architecture

VIPER
VIPERVIPER
VIPER
Vikas Kore
 
Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)Shubham Goenka
 
Internship-Report-VitulChauhan-18132023-IT_CRUD-OPERATION.pdf
Internship-Report-VitulChauhan-18132023-IT_CRUD-OPERATION.pdfInternship-Report-VitulChauhan-18132023-IT_CRUD-OPERATION.pdf
Internship-Report-VitulChauhan-18132023-IT_CRUD-OPERATION.pdf
VitulChauhan
 
software architecture
software architecturesoftware architecture
software architecture
arnav gupta
 
demystifying_the_architectures_of_a_mobile_app_development.pdf
demystifying_the_architectures_of_a_mobile_app_development.pdfdemystifying_the_architectures_of_a_mobile_app_development.pdf
demystifying_the_architectures_of_a_mobile_app_development.pdf
sarah david
 
Over view of software artitecture
Over view of software artitectureOver view of software artitecture
Over view of software artitecture
ABDEL RAHMAN KARIM
 
demystifying_the_architectures_of_a_mobile_app_development.pptx
demystifying_the_architectures_of_a_mobile_app_development.pptxdemystifying_the_architectures_of_a_mobile_app_development.pptx
demystifying_the_architectures_of_a_mobile_app_development.pptx
sarah david
 
Angular.js interview questions
Angular.js interview questionsAngular.js interview questions
Angular.js interview questions
codeandyou forums
 
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
IRJET Journal
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
naral
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
Boulos Dib
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast track
Binu Bhasuran
 
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
RapidValue
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
Ahmed Emad
 
FRONTEND DEVELOPMENT WITH REACT.JS
FRONTEND DEVELOPMENT WITH REACT.JSFRONTEND DEVELOPMENT WITH REACT.JS
FRONTEND DEVELOPMENT WITH REACT.JS
IRJET Journal
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptx
SafnaSaff1
 
Comparing AngularJS and ReactJS_ Finding the Best Framework for your Next Pro...
Comparing AngularJS and ReactJS_ Finding the Best Framework for your Next Pro...Comparing AngularJS and ReactJS_ Finding the Best Framework for your Next Pro...
Comparing AngularJS and ReactJS_ Finding the Best Framework for your Next Pro...
JPLoft Solutions
 
Application for Data Sync Between Different geo Locations
Application for Data Sync Between Different geo LocationsApplication for Data Sync Between Different geo Locations
Application for Data Sync Between Different geo LocationsMike Taylor
 
Password security system for websites
Password security system for websitesPassword security system for websites
Password security system for websites
Mike Taylor
 
How Android Architecture Components can Help You Improve Your App’s Design?
How Android Architecture Components can Help You Improve Your App’s Design?How Android Architecture Components can Help You Improve Your App’s Design?
How Android Architecture Components can Help You Improve Your App’s Design?
Paul Cook
 

Similar to VIPER Architecture (20)

VIPER
VIPERVIPER
VIPER
 
Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)
 
Internship-Report-VitulChauhan-18132023-IT_CRUD-OPERATION.pdf
Internship-Report-VitulChauhan-18132023-IT_CRUD-OPERATION.pdfInternship-Report-VitulChauhan-18132023-IT_CRUD-OPERATION.pdf
Internship-Report-VitulChauhan-18132023-IT_CRUD-OPERATION.pdf
 
software architecture
software architecturesoftware architecture
software architecture
 
demystifying_the_architectures_of_a_mobile_app_development.pdf
demystifying_the_architectures_of_a_mobile_app_development.pdfdemystifying_the_architectures_of_a_mobile_app_development.pdf
demystifying_the_architectures_of_a_mobile_app_development.pdf
 
Over view of software artitecture
Over view of software artitectureOver view of software artitecture
Over view of software artitecture
 
demystifying_the_architectures_of_a_mobile_app_development.pptx
demystifying_the_architectures_of_a_mobile_app_development.pptxdemystifying_the_architectures_of_a_mobile_app_development.pptx
demystifying_the_architectures_of_a_mobile_app_development.pptx
 
Angular.js interview questions
Angular.js interview questionsAngular.js interview questions
Angular.js interview questions
 
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
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast track
 
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
FRONTEND DEVELOPMENT WITH REACT.JS
FRONTEND DEVELOPMENT WITH REACT.JSFRONTEND DEVELOPMENT WITH REACT.JS
FRONTEND DEVELOPMENT WITH REACT.JS
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptx
 
Comparing AngularJS and ReactJS_ Finding the Best Framework for your Next Pro...
Comparing AngularJS and ReactJS_ Finding the Best Framework for your Next Pro...Comparing AngularJS and ReactJS_ Finding the Best Framework for your Next Pro...
Comparing AngularJS and ReactJS_ Finding the Best Framework for your Next Pro...
 
Application for Data Sync Between Different geo Locations
Application for Data Sync Between Different geo LocationsApplication for Data Sync Between Different geo Locations
Application for Data Sync Between Different geo Locations
 
Password security system for websites
Password security system for websitesPassword security system for websites
Password security system for websites
 
How Android Architecture Components can Help You Improve Your App’s Design?
How Android Architecture Components can Help You Improve Your App’s Design?How Android Architecture Components can Help You Improve Your App’s Design?
How Android Architecture Components can Help You Improve Your App’s Design?
 

VIPER Architecture

Editor's Notes

  1. VIPER - Architecture approach for application development(particularly iOS) , based on the Clean Architecture by Robert C. Martin (Uncle Bob).
  2. Conform to the Single Responsibility Principle (Every module or class should have responsibility over a single part of the functionality). Presentation level: UI layer, view layer In simple terms, it is a layer which users can access directly (such as a web page, or an operating system's GUI). The Single Responsibility Principle (Every module or class should have responsibility over a single part of the functionality).
  3. An article Introduction to VIPER by MutualMobile. Issue #13. objc.io Architecting iOS Apps with VIPER by MutualMobile publishes books on advanced techniques and practices for iOS and OS X development Mutual Mobile is an emerging tech agency that builds breakthrough products for a more connected world.
  4. Big and Long-Term Project What is the best Architecture?
  5. UIViewController class defines the methods and properties for managing your views, handling events, transitioning from one view controller to another, and coordinating with other parts of your app. Data sources for Views (UITableViews). Business Logic . Application Flows (Manage the life cycles). Transition between view controller.
  6. Large files (+1000 lines) . A lot of unstructured code. High complexity. Untestable code.
  7. In software and systems engineering, a use case is a list of actions or event steps, typically defining the interactions between a role (known in the Unified Modeling Language as an actor) and a system, to achieve a goal. The actor can be a human or other external system. Use cases are a type of textual requirements specification that capture how a user will interact with a solution to achieve a specific goal. They describe the step by step process a user goes through to complete that goal using a software system.
  8. Used by the Interactor.
  9. Use cases are a type of textual requirements specification that capture how a user will interact with a solution to achieve a specific goal. They describe the step by step process a user goes through to complete that goal using a software system. Fetch Save specific data. Sort data
  10. The design conventions, APIs, and programming patterns are the same. You’ll use the same Foundation classes - collection sets, strings, numbers… nothing new here at all. An NSArray is still an NSArray. Of course, when it comes to the UI, the complexity starts to increase. In iOS you’re used to dealing with a straightforward view progression. The user always moves from one view to the next, and as developer you control that linearly. On the desktop, you may begin with multiple windows, progress with spawning new or closing windows, respond to events from the menu bar, handle undos, and so on. In short, there are a lot more things to keep track of.
  11. Where should this networking take place? It’s up to the Interactor to initiate a network operation, but it won’t handle the networking code. What should be responsible for initiating it? It will ask a dependency, like a network manager.
  12. The View is an abstract interface, defined in Swift with a protocol. A UIViewController or one of its subclasses will implement the View protocol.
  13. Consists logic to drive the UI. Do not know about the existence of UILabel, UIButton, etc.
  14. Set image from car resuts to car view
  15. Storyboards are a great way to implement the layout for your user interface using Auto Layout.
  16. The module’s Presenter usually implements the module interface. When another module wants to present this one, its Presenter will implement the module delegate protocol.
  17. A concern is a set of information that affects the code of a computer program. In computer science, separation of concerns (SoC) is a design principle for separating a computer program into distinct sections, such that each section addresses a separate concern
  18. Need more sreenshots.