SlideShare a Scribd company logo
Architectural Design
Pattern
MVC, MVP & MVVM
What & Why
Design Pattern
What is Design Pattern
In software engineering, a design pattern is a general repeatable solution to a commonly
occurring problem in software design. A design pattern isn't a finished design that can be
transformed directly into code. It is a description or template for how to solve a problem that can
be used in many different situations.
Need of Design Pattern?
1. To solve a recurring problem in software development
1. To represent a relationships between classes and objects with defined
responsibilities to carry out the solution in a concrete way
1. To develop highly cohesive modules with minimal coupling
Requirement &
Implementation
Design Pattern
Problem Statement
Consider the following story -
Story: As a user, i must be able to get a successful status so that i can find out
whether user id and password given by me is correct or not.
Model: UserInfo(userId, password)
View: InputBox(userId), InputBox(password), actionButton
Note: For the story above, Model and View will remain same and we will see how to implement them in MVC, MVP and
MVVM.
Solution
Design Pattern: MVC
M V & Controller
Consider designing a Login Controller with a method onLogin which will execute when login button gets clicked
in View defined in problem statement
LoginController{
doLogin(String userId, String password){
//PERFORM OPERATION FOR PROCESSING THE LOGIN DETAIL
//ACT ON OR DELEGATE RESULT TO VIEW
}
M V & Controller
Now, during the integration of LoginController with View, there is no mandatory rule to delegate result to View
by using Java Interface and there may be chance that the result gets processed inline in View itself and we
found this being an average case of development.
//VIEW
onLogin(String userId, String password){
loginController.doLogin(userId, password){
dataManager.verifyLogin(userId, password){
onSuccess(){ // INLINE CODE TO SHOW SUCCESS }
onFailure(){ // INLINE CODE TO SHOW FAILURE }
} } }
M V & Controller
And so following being a rule in MVC for to solve the problem statement
Action in the View(Activity/Fragment)
-> Call to Controller
-> Controller Logic
-> Controller returns the View.
-where in last step, there is no restriction to let the View handle the result.
-Also the controllers are not restricted to be used for single view and can be shared among
multiple views
MVC: Flow Diagram
Following is the flow diagram in MVC
-Note: Image has been taken from internet
MVC: Interaction
Following is the interaction flow in MVC
-Note: Image has been taken from internet
Solution
Design Pattern: MVP
M V & Presenter
Consider the case with a LoginPresenter and same method
LoginController{
doLogin(String userId, String password){
//PERFORM OPERATION FOR PROCESSING THE LOGIN DETAIL
//ACT ON OR DELEGATE RESULT TO VIEW VIA A CONTRACT/INTERFACE
}
M V & Presenter
Now, integration of LoginPresenter with View requires the View to implement the CONTRACT/INTERFACE
defined to process the result delegated from Presenter
//VIEW
onLogin(String userId, String password){
loginPresenter..doLogin(userId, password);
}
onSuccess(){ //THE CONTRACT METHOD FOR LOGIN FROM INTERFACE}
onFailure(){ //THE CONTRACT METHOD FOR LOGIN FROM INTERFACE}
M V & Presenter
Action in the View(Activity/Fragment)
-> Notify to Presenter
- Presenter Logic
<- Revert back to update the View.
-where in last step, there is a restriction to let the View handle the result avoiding chances of
developers writing the inline code in View.
-90% of Presenter are having a 1-on-1 relation with View, and in very complex requirement, it
gets shared when needed.
MVP: Flow Diagram
Following is the flow diagram in MVP
-Note: Image has been taken from internet
MVP: Interaction
Following is the interaction flow in MVP
-Note: Image has been taken from internet
Solution
Design Pattern: MVVM
M V & ViewModel
ViewModel remains same as the Presenter but it gets implemented with 2-way DataBinding
Data binding : It is the process that binds the View with business logic lying at ViewModel layer. Android
comes with DataBinding Library to serve this purpose. If the binding is correctly set, then, when the data
changes its value, the elements that are bound to the data reflect changes automatically releasing the load of
ViewModel to delegate results each time.
Presenters, in MVP, can also use DataBinding making them tend towards MVVM and when it is done with 2-way
binding, it becomes MVVM.
M V & ViewModel
Following being a rule in MVVM
Action in the View(Activity/Fragment)
- Bound with ViewModel
- ViewModel Logic
- Revert back to notify the View, if required
MVVM: Flow Diagram
Following is the interaction flow in MVVM
-Note: Image has been taken from internet
Which one is better?
There is no wrong in using any of the patterns, but to reduce code and restrict your developer
making mistakes, i would personally recommend to go for MVP with binding, somewhere 1-way
ans/or 2-way.
It depends on how best you can follow the rules and guidelines and how much your development
is vulnerable to violate the rules & guidelines
References
StarterKit-MVP This is a first version of mvp based baseline project. This is designed to create as a starter-kit
project for Android platform based on MVP, making it easier to develop project features/modules on top of it.
StarterKit-MVVM: This is a first version of mvvm based baseline project. This is designed to create as a starter-
kit project for Android platform based on MVVM, making it easier to develop project features/modules on top of
it.
Both Starter-Kit uses a network library wrapped on top of Retrofit named Networx.
Starter-Kit: This project contains mainly MVP and MVVM design pattern using Retrofit.It also has MVVM using
RxNetwork. The purpose of Starter-Kit is to create a baseline project based on making it easier to develop project
features/modules on top of it.
These are first version of baseline projects and feedback are invited for improving it further.
Thank You
Share your feedback to-
Email: inbox.jkumar@gmail.com
Twitter: twitbox_jkumar
LinkedIn: https://www.linkedin.com/in/connect2jkumar/
Ad

More Related Content

What's hot (20)

Modern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Modern Software Architectures: Building Solutions for Web, Cloud, and MobileModern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Modern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Dan Mohl
 
Large-Scale JavaScript Development
Large-Scale JavaScript DevelopmentLarge-Scale JavaScript Development
Large-Scale JavaScript Development
Addy Osmani
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
Jonas Follesø
 
Facade pattern
Facade patternFacade pattern
Facade pattern
JAINIK PATEL
 
Class 02 Objective C
Class 02   Objective CClass 02   Objective C
Class 02 Objective C
Violeta Salas
 
MVC
MVCMVC
MVC
Ravi Bansal
 
Facade Design Pattern
Facade Design PatternFacade Design Pattern
Facade Design Pattern
Livares Technologies Pvt Ltd
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
Sudarsun Santhiappan
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
Jiby John
 
Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)
Aniruddha Chakrabarti
 
當ZK遇見Front-End
當ZK遇見Front-End當ZK遇見Front-End
當ZK遇見Front-End
祁源 朱
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
Qamar Abbas
 
Facade pattern
Facade patternFacade pattern
Facade pattern
Shakil Ahmed
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade Pattern
Mudasir Qazi
 
Facade Pattern
Facade PatternFacade Pattern
Facade Pattern
melbournepatterns
 
Design pattern
Design patternDesign pattern
Design pattern
Omar Isaid
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
Carles Farré
 
Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)
VishalChavan83
 
Mvvm basics
Mvvm basicsMvvm basics
Mvvm basics
anusha kadimi
 
Presentation facade design pattern
Presentation facade design patternPresentation facade design pattern
Presentation facade design pattern
Bayu Firmawan Paoh
 
Modern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Modern Software Architectures: Building Solutions for Web, Cloud, and MobileModern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Modern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Dan Mohl
 
Large-Scale JavaScript Development
Large-Scale JavaScript DevelopmentLarge-Scale JavaScript Development
Large-Scale JavaScript Development
Addy Osmani
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
Jonas Follesø
 
Class 02 Objective C
Class 02   Objective CClass 02   Objective C
Class 02 Objective C
Violeta Salas
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
Jiby John
 
當ZK遇見Front-End
當ZK遇見Front-End當ZK遇見Front-End
當ZK遇見Front-End
祁源 朱
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
Qamar Abbas
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade Pattern
Mudasir Qazi
 
Design pattern
Design patternDesign pattern
Design pattern
Omar Isaid
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
Carles Farré
 
Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)
VishalChavan83
 
Presentation facade design pattern
Presentation facade design patternPresentation facade design pattern
Presentation facade design pattern
Bayu Firmawan Paoh
 

Viewers also liked (20)

Android (software) Design Pattern
Android (software) Design PatternAndroid (software) Design Pattern
Android (software) Design Pattern
Arif Huda
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software Engineering
Manish Kumar
 
Architectural Design Concepts Approaches - كونسيبت التصميم المعمارى و الفكرة ...
Architectural Design Concepts Approaches - كونسيبت التصميم المعمارى و الفكرة ...Architectural Design Concepts Approaches - كونسيبت التصميم المعمارى و الفكرة ...
Architectural Design Concepts Approaches - كونسيبت التصميم المعمارى و الفكرة ...
Galala University
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
Leslie Samuel
 
10 strategy pattern
10 strategy pattern10 strategy pattern
10 strategy pattern
Abhijit Gaikwad
 
How to build your own Hybrid JS Interface with Android?
How to build your own Hybrid JS Interface with Android?How to build your own Hybrid JS Interface with Android?
How to build your own Hybrid JS Interface with Android?
swagat parida
 
Architecture Description Languages: An Overview
Architecture Description Languages: An OverviewArchitecture Description Languages: An Overview
Architecture Description Languages: An Overview
elliando dias
 
5 Steps To Clean Your Android Code
5 Steps To Clean Your Android Code5 Steps To Clean Your Android Code
5 Steps To Clean Your Android Code
Frankie Sardo
 
ANDROID TRAINING IN CHENNAI
ANDROID TRAINING IN CHENNAIANDROID TRAINING IN CHENNAI
ANDROID TRAINING IN CHENNAI
Jahan Murugassan
 
Android notifications. testing guideline
Android notifications. testing guidelineAndroid notifications. testing guideline
Android notifications. testing guideline
TechMagic
 
Facebook hiring 6.0
Facebook hiring 6.0Facebook hiring 6.0
Facebook hiring 6.0
Ranjan Sinha
 
Device fragmentation vs clean code
Device fragmentation vs clean codeDevice fragmentation vs clean code
Device fragmentation vs clean code
Iordanis (Jordan) Giannakakis
 
Clean code on Android (Droidcon Dubai 2015)
Clean code on Android (Droidcon Dubai 2015)Clean code on Android (Droidcon Dubai 2015)
Clean code on Android (Droidcon Dubai 2015)
Danny Preussler
 
Strategy Pattern
Strategy PatternStrategy Pattern
Strategy Pattern
Shahriar Iqbal Chowdhury
 
8990 Holdings - COL Financial presentation
8990 Holdings - COL Financial presentation 8990 Holdings - COL Financial presentation
8990 Holdings - COL Financial presentation
8990HOUSE
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator Pattern
Akshat Vig
 
android design pattern
android design patternandroid design pattern
android design pattern
Lucas Xu
 
W06.01 Summary Affordable Homes: Building mass housing in India
W06.01 Summary Affordable Homes: Building mass housing in IndiaW06.01 Summary Affordable Homes: Building mass housing in India
W06.01 Summary Affordable Homes: Building mass housing in India
Shuvashish Chatterjee
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Pankhuree Srivastava
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
eprafulla
 
Android (software) Design Pattern
Android (software) Design PatternAndroid (software) Design Pattern
Android (software) Design Pattern
Arif Huda
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software Engineering
Manish Kumar
 
Architectural Design Concepts Approaches - كونسيبت التصميم المعمارى و الفكرة ...
Architectural Design Concepts Approaches - كونسيبت التصميم المعمارى و الفكرة ...Architectural Design Concepts Approaches - كونسيبت التصميم المعمارى و الفكرة ...
Architectural Design Concepts Approaches - كونسيبت التصميم المعمارى و الفكرة ...
Galala University
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
Leslie Samuel
 
How to build your own Hybrid JS Interface with Android?
How to build your own Hybrid JS Interface with Android?How to build your own Hybrid JS Interface with Android?
How to build your own Hybrid JS Interface with Android?
swagat parida
 
Architecture Description Languages: An Overview
Architecture Description Languages: An OverviewArchitecture Description Languages: An Overview
Architecture Description Languages: An Overview
elliando dias
 
5 Steps To Clean Your Android Code
5 Steps To Clean Your Android Code5 Steps To Clean Your Android Code
5 Steps To Clean Your Android Code
Frankie Sardo
 
ANDROID TRAINING IN CHENNAI
ANDROID TRAINING IN CHENNAIANDROID TRAINING IN CHENNAI
ANDROID TRAINING IN CHENNAI
Jahan Murugassan
 
Android notifications. testing guideline
Android notifications. testing guidelineAndroid notifications. testing guideline
Android notifications. testing guideline
TechMagic
 
Facebook hiring 6.0
Facebook hiring 6.0Facebook hiring 6.0
Facebook hiring 6.0
Ranjan Sinha
 
Clean code on Android (Droidcon Dubai 2015)
Clean code on Android (Droidcon Dubai 2015)Clean code on Android (Droidcon Dubai 2015)
Clean code on Android (Droidcon Dubai 2015)
Danny Preussler
 
8990 Holdings - COL Financial presentation
8990 Holdings - COL Financial presentation 8990 Holdings - COL Financial presentation
8990 Holdings - COL Financial presentation
8990HOUSE
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator Pattern
Akshat Vig
 
android design pattern
android design patternandroid design pattern
android design pattern
Lucas Xu
 
W06.01 Summary Affordable Homes: Building mass housing in India
W06.01 Summary Affordable Homes: Building mass housing in IndiaW06.01 Summary Affordable Homes: Building mass housing in India
W06.01 Summary Affordable Homes: Building mass housing in India
Shuvashish Chatterjee
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
eprafulla
 
Ad

Similar to Architectural Design Pattern: Android (20)

MVVM presentation
MVVM presentationMVVM presentation
MVVM presentation
Inova LLC
 
Code Camp 06 Model View Presenter Architecture
Code Camp 06   Model View Presenter ArchitectureCode Camp 06   Model View Presenter Architecture
Code Camp 06 Model View Presenter Architecture
bitburner93
 
MV(C, mvvm) in iOS and ReactiveCocoa
MV(C, mvvm) in iOS and ReactiveCocoaMV(C, mvvm) in iOS and ReactiveCocoa
MV(C, mvvm) in iOS and ReactiveCocoa
Yi-Shou Chen
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptx
SafnaSaff1
 
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
 
реалии использования Mv в i os разработке
реалии использования Mv в i os разработкереалии использования Mv в i os разработке
реалии использования Mv в i os разработке
Provectus
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
Dipika Wadhvani
 
Exploring MVVM, MVC, MVP Patterns - CRB Tech
Exploring MVVM, MVC, MVP Patterns - CRB TechExploring MVVM, MVC, MVP Patterns - CRB Tech
Exploring MVVM, MVC, MVP Patterns - CRB Tech
Pooja Gaikwad
 
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
Mvc vs mvp vs mvvm  a guide on architecture presentation patternsMvc vs mvp vs mvvm  a guide on architecture presentation patterns
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
Concetto Labs
 
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
 
Design Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVMDesign Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVM
Mudasir Qazi
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For Android
InnovationM
 
Mvvw patterns
Mvvw patternsMvvw patterns
Mvvw patterns
eleksdev
 
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
Jinkyu Kim
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
Edureka!
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
Boulos Dib
 
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
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development services
Aaron Jacobson
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For Android
InnovationM
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For Android
InnovationM
 
MVVM presentation
MVVM presentationMVVM presentation
MVVM presentation
Inova LLC
 
Code Camp 06 Model View Presenter Architecture
Code Camp 06   Model View Presenter ArchitectureCode Camp 06   Model View Presenter Architecture
Code Camp 06 Model View Presenter Architecture
bitburner93
 
MV(C, mvvm) in iOS and ReactiveCocoa
MV(C, mvvm) in iOS and ReactiveCocoaMV(C, mvvm) in iOS and ReactiveCocoa
MV(C, mvvm) in iOS and ReactiveCocoa
Yi-Shou Chen
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptx
SafnaSaff1
 
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
 
реалии использования Mv в i os разработке
реалии использования Mv в i os разработкереалии использования Mv в i os разработке
реалии использования Mv в i os разработке
Provectus
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
Dipika Wadhvani
 
Exploring MVVM, MVC, MVP Patterns - CRB Tech
Exploring MVVM, MVC, MVP Patterns - CRB TechExploring MVVM, MVC, MVP Patterns - CRB Tech
Exploring MVVM, MVC, MVP Patterns - CRB Tech
Pooja Gaikwad
 
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
Mvc vs mvp vs mvvm  a guide on architecture presentation patternsMvc vs mvp vs mvvm  a guide on architecture presentation patterns
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
Concetto Labs
 
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
 
Design Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVMDesign Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVM
Mudasir Qazi
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For Android
InnovationM
 
Mvvw patterns
Mvvw patternsMvvw patterns
Mvvw patterns
eleksdev
 
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
Jinkyu Kim
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
Edureka!
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
Boulos Dib
 
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
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development services
Aaron Jacobson
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For Android
InnovationM
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For Android
InnovationM
 
Ad

Recently uploaded (20)

Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 

Architectural Design Pattern: Android

  • 3. What is Design Pattern In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.
  • 4. Need of Design Pattern? 1. To solve a recurring problem in software development 1. To represent a relationships between classes and objects with defined responsibilities to carry out the solution in a concrete way 1. To develop highly cohesive modules with minimal coupling
  • 6. Problem Statement Consider the following story - Story: As a user, i must be able to get a successful status so that i can find out whether user id and password given by me is correct or not. Model: UserInfo(userId, password) View: InputBox(userId), InputBox(password), actionButton Note: For the story above, Model and View will remain same and we will see how to implement them in MVC, MVP and MVVM.
  • 8. M V & Controller Consider designing a Login Controller with a method onLogin which will execute when login button gets clicked in View defined in problem statement LoginController{ doLogin(String userId, String password){ //PERFORM OPERATION FOR PROCESSING THE LOGIN DETAIL //ACT ON OR DELEGATE RESULT TO VIEW }
  • 9. M V & Controller Now, during the integration of LoginController with View, there is no mandatory rule to delegate result to View by using Java Interface and there may be chance that the result gets processed inline in View itself and we found this being an average case of development. //VIEW onLogin(String userId, String password){ loginController.doLogin(userId, password){ dataManager.verifyLogin(userId, password){ onSuccess(){ // INLINE CODE TO SHOW SUCCESS } onFailure(){ // INLINE CODE TO SHOW FAILURE } } } }
  • 10. M V & Controller And so following being a rule in MVC for to solve the problem statement Action in the View(Activity/Fragment) -> Call to Controller -> Controller Logic -> Controller returns the View. -where in last step, there is no restriction to let the View handle the result. -Also the controllers are not restricted to be used for single view and can be shared among multiple views
  • 11. MVC: Flow Diagram Following is the flow diagram in MVC -Note: Image has been taken from internet
  • 12. MVC: Interaction Following is the interaction flow in MVC -Note: Image has been taken from internet
  • 14. M V & Presenter Consider the case with a LoginPresenter and same method LoginController{ doLogin(String userId, String password){ //PERFORM OPERATION FOR PROCESSING THE LOGIN DETAIL //ACT ON OR DELEGATE RESULT TO VIEW VIA A CONTRACT/INTERFACE }
  • 15. M V & Presenter Now, integration of LoginPresenter with View requires the View to implement the CONTRACT/INTERFACE defined to process the result delegated from Presenter //VIEW onLogin(String userId, String password){ loginPresenter..doLogin(userId, password); } onSuccess(){ //THE CONTRACT METHOD FOR LOGIN FROM INTERFACE} onFailure(){ //THE CONTRACT METHOD FOR LOGIN FROM INTERFACE}
  • 16. M V & Presenter Action in the View(Activity/Fragment) -> Notify to Presenter - Presenter Logic <- Revert back to update the View. -where in last step, there is a restriction to let the View handle the result avoiding chances of developers writing the inline code in View. -90% of Presenter are having a 1-on-1 relation with View, and in very complex requirement, it gets shared when needed.
  • 17. MVP: Flow Diagram Following is the flow diagram in MVP -Note: Image has been taken from internet
  • 18. MVP: Interaction Following is the interaction flow in MVP -Note: Image has been taken from internet
  • 20. M V & ViewModel ViewModel remains same as the Presenter but it gets implemented with 2-way DataBinding Data binding : It is the process that binds the View with business logic lying at ViewModel layer. Android comes with DataBinding Library to serve this purpose. If the binding is correctly set, then, when the data changes its value, the elements that are bound to the data reflect changes automatically releasing the load of ViewModel to delegate results each time. Presenters, in MVP, can also use DataBinding making them tend towards MVVM and when it is done with 2-way binding, it becomes MVVM.
  • 21. M V & ViewModel Following being a rule in MVVM Action in the View(Activity/Fragment) - Bound with ViewModel - ViewModel Logic - Revert back to notify the View, if required
  • 22. MVVM: Flow Diagram Following is the interaction flow in MVVM -Note: Image has been taken from internet
  • 23. Which one is better? There is no wrong in using any of the patterns, but to reduce code and restrict your developer making mistakes, i would personally recommend to go for MVP with binding, somewhere 1-way ans/or 2-way. It depends on how best you can follow the rules and guidelines and how much your development is vulnerable to violate the rules & guidelines
  • 24. References StarterKit-MVP This is a first version of mvp based baseline project. This is designed to create as a starter-kit project for Android platform based on MVP, making it easier to develop project features/modules on top of it. StarterKit-MVVM: This is a first version of mvvm based baseline project. This is designed to create as a starter- kit project for Android platform based on MVVM, making it easier to develop project features/modules on top of it. Both Starter-Kit uses a network library wrapped on top of Retrofit named Networx. Starter-Kit: This project contains mainly MVP and MVVM design pattern using Retrofit.It also has MVVM using RxNetwork. The purpose of Starter-Kit is to create a baseline project based on making it easier to develop project features/modules on top of it. These are first version of baseline projects and feedback are invited for improving it further.
  • 25. Thank You Share your feedback to- Email: [email protected] Twitter: twitbox_jkumar LinkedIn: https://www.linkedin.com/in/connect2jkumar/