SlideShare a Scribd company logo
UI Design Patterns
Jorge D. Ortiz Fuentes
PoWWaU
Agenda
★Context on design patterns
★MVC
★MVP
★MVVM
★Lessons Learned
2
Intro
★MVVM hotness
★Problems with testability
3
Disclaimer
★Not an expert
★Lack of code here
★Opinionated
4
Some assumptions
★Core Data for persistence
★As few external dependencies
as possible (i.e., no
Reactive Cocoa)
★Examples referred to iOS.
(Many similarities with OS X,
but some differences too)
5
Design Patterns
★Predefined solutions to common
problems with additional benefits:
๏Reusable
๏Loosely coupled
★Some examples:
๏Singleton
๏Delegate
๏Observer
6
Defining a design pattern
1. Name
2. Problem
3. Solution
4. Consequences
7
Painful truth
"Different people reading about MVC in
different places take different ideas from it
and describe these as 'MVC'. If this doesn't
cause enough confusion you then get the
effect of misunderstandings of MVC that
develop through a system of Chinese
whispers.”	

Martin Fowler	

Painful truth
A tricky question
If [Model] + [View] + [Controller
/ Presenter / View Model] =
[TheApp]
How can Controller != Presenter !
= View Model?
★Responsibilities matter!
★Other components (patterns)
might be involved.
10
The goal
★Separation of responsibilities
into roles. Is it? Not
historically. Other motivations.
Solving problem d’jour.
★Now why?
๏Testability
๏Reusability
๏Extensibility
11
Responsibilities
★Handle low level events
★Handle high level events
★Update user interface
★Apply changes to the domain
model
★Presentation logic
★More…
12
MVC: The early days
MVC: The early days
★View
๏Visual representation of the model
๏Receives references to the model to
know the data to display. (Not too
reusable views)
★Controller
๏Deals with user input, app <-> human
(old paradigmas)
๏Shows the widgets change and tell the
model what to do.
★Model
๏Data and business functionality
(domain).
๏No references to the UI.
๏It is observable.
๏Display logic is part of the model.
Ctrlr
ModelView
MVC: The early days
★Separated presentation: Model
<-> Presentation (= V+C)
★Observer originated from MVC,
but observing full object
(properties = scalars)
★Variations: Passive model The
model cannot send updates
(for example HTTP)
15
Apple’s MVC
Apple’s MVC
★View
๏Only UIView subclasses
๏Show information and handle input to generate
higher level events passed to controller
๏Fully reusable views library. Consistent L&F
★Controller
๏Views delegate / control what’s displayed
๏Receive the events and converts them into
calls to the model.
๏_Knows_ about changes in the model and update
what is displayed on the view. Typically a
UIViewController. Responsible of presentation
logic.
★Model
๏Contain the business logic. No references to
the UI.
Flow synchronization vs Observer synchronization
MVC = Composite + Strategy + Observer
Ctrlr
ModelView
MVC Code Distribution
★Model:
๏NSManagedObjectModel,
NSPersistentStore,
NSPersistentCoordinator,
NSManagedObjectContext
๏NSManagedObject
subclasses and its
categories (or additional
methods)
๏UIManagedDocument
๏NSFetchRequests
★Controller:
๏Theme
๏Observer
๏Targets/selectors for the
views actions
๏View delegates
๏Presentation logic
๏NSFetchedResultsControlle
r
★Views:
๏UIButton, UILabel,
UITableView...
Apple’s MVC: testability
★The views are somebody else's (Apple's)
problem.
★Model is easy to test.
★Controller is huge & has dependencies
on the model and on the views. =>
Complex to test.
★Too many levels of abstraction, only a
few methods exposed.
★Some stuff in view controller that it
is usually not tested.
19
MVP
MVP
Origin: IBM & Taligent (=IBM + Apple)
★View
๏Shows information and process the
input gestures transferring control
to the presenter.
๏View is updated using the observer
pattern.
★Presenter
๏Respond to high level events (user
acts)
๏Generates commands (Command
pattern) for the model. (Easy undo
redo)
★Model
๏Receives the commands and acts on
the domain information
Prstr
CmdsInteract
ModelView
Selec
MVP Code Distribution
★Model:
๏NSManagedObjectModel,
NSPersistentStore,
NSPersistentCoordinator,
NSManagedObjectContext, &
UIManagedDocument
๏NSManagedObject subclasses and
its categories (or additional
methods).
๏NSFetchRequests
★Selections:
๏NSFetchedResultsController
★Commands:
๏NSInvocation / NSUndoManager
★Presenter:
๏Observer
๏Targets/selectors for the
views actions & View
delegates.
๏Presentation logic
๏View controller
★Interactors:
๏Gesture recognizers
★Views:
๏UIButton, UILabel…
MVP testability
★Apple's MVC is closer to this than to
classic MVC (Even more compared to the
Dolphin MVP).
★View Controller belongs with the view.
★Properties are now objects, instead of
scalars, so observation is per property.
Easier to deal with indirect invocations.
★More parts, more difficult to write, but
easier to test and reuse.
★If model uses Core Data the command
pattern is almost there (undo/redo).
23
MVVM
MVVM
★View
๏Shows information and process the
input gestures transferring control
to the presenter
๏View is updated using the observer
pattern. View + View Controller
๏Responsible for display logic,
themes...
★View Model
๏Respond to high level events (user
acts) Provides calls to the View
(invoked via the view controller)
๏Validation logic.
★Model
๏Receives the commands and acts on
the domain information
VM
VC
ModelView
MVVM Testability
★The view controller is conceptually attached to the
view role.
★The View Model would be the same for different
platforms, since there isn't any specific mention of
the views.
★Presentation logic (like formatting strings) belongs
to the model. Easier to test exposed methods.
★MVVM is the E&E (embrace and extend) version of MVP.
★Data binding is NOT a key difference.
★Rx programming claim increased testability:
๏doesn't need shared mutable state
๏can be composed
๏no callback hell.
26
MVVM Code Distribution
★Model:
๏NSManagedObjectModel,
NSPersistentStore,
NSPersistentCoordinator,
NSManagedObjectContext, &
UIManagedDocument
๏NSManagedObject subclasses
and its categories (or
additional methods).
๏NSFetchRequests
★View Model:
๏NSFetchedResultsController
๏Observer
๏Targets/selectors for the
views actions & View
delegates.
๏Presentation logic
๏NSInvocation /
NSUndoManager
★Views:
๏UIButton, UILabel…
๏View controller
๏Gesture recognizers
Lessons Learned
Lessons Learned
★Same name used for different
patterns.
★Good to understand patterns
for your business (& mental
health).
★A range of possibilities =
trade offs.
29
References
★Alfonso Alba García
“Bienvenido a la república
independiente de las pruebas
unitarias con Core Data”,
2013

http://es.slideshare.net/
aalbagarcia/bienvenido-a-la-
republica-independiente
★The Gang of 4, “Design
Patterns: Elements of
Reusable Object-Oriented
Software”, 1994
★Derek Greer “Interactive
Application Architecture
Patterns”, 2007

http://aspiringcraftsman.com/
2007/08/25/interactive-
application-architecture/
★Martin Fowler, "Patterns of
Enterprise Application
Architecture”, 2002
★Martin Fowler, “GUI
Architectures”, 2006

http://martinfowler.com/
eaaDev/uiArchs.html
★Ash Furrow “Model-View-
ViewModel for iOS”, 2014

http://www.teehanlax.com/
blog/model-view-viewmodel-
for-ios/
Thank you!

More Related Content

What's hot

MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentation
G ABHISEK
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnet
rainynovember12
 
MVC Seminar Presantation
MVC Seminar PresantationMVC Seminar Presantation
MVC Seminar Presantation
Abhishek Yadav
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
Mvvm basics
Mvvm basicsMvvm basics
Mvvm basics
anusha kadimi
 
Introduction To Model View Presenter
Introduction To Model View PresenterIntroduction To Model View Presenter
Introduction To Model View Presenter
saeed shargi ghazani
 
Mvc fundamental
Mvc fundamentalMvc fundamental
Mvc fundamental
Nguyễn Thành Phát
 
MVVM presentation
MVVM presentationMVVM presentation
MVVM presentation
Inova LLC
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
Dipika Wadhvani
 
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
 
What is MVC?
What is MVC?What is MVC?
What is MVC?
Dominique Cimafranca
 
MVC architecture
MVC architectureMVC architecture
MVC architecture
Emily Bauman
 
MVVM - Model View ViewModel
MVVM - Model View ViewModelMVVM - Model View ViewModel
MVVM - Model View ViewModel
Dareen Alhiyari
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
Jonas Follesø
 
Mvc pattern and implementation in java fair
Mvc   pattern   and implementation   in   java fairMvc   pattern   and implementation   in   java fair
Mvc pattern and implementation in java fairTech_MX
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
allanh0526
 
Introduction to mvc architecture
Introduction to mvc architectureIntroduction to mvc architecture
Introduction to mvc architecture
ravindraquicsolv
 
Why Use MVC?
Why Use MVC?Why Use MVC?
Why Use MVC?
Jesse Anderson
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
Wayne Tun Myint
 

What's hot (20)

MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentation
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnet
 
MVC Seminar Presantation
MVC Seminar PresantationMVC Seminar Presantation
MVC Seminar Presantation
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Mvvm basics
Mvvm basicsMvvm basics
Mvvm basics
 
Introduction To Model View Presenter
Introduction To Model View PresenterIntroduction To Model View Presenter
Introduction To Model View Presenter
 
Mvc fundamental
Mvc fundamentalMvc fundamental
Mvc fundamental
 
MVVM presentation
MVVM presentationMVVM presentation
MVVM presentation
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
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
 
What is MVC?
What is MVC?What is MVC?
What is MVC?
 
MVC Architecture
MVC ArchitectureMVC Architecture
MVC Architecture
 
MVC architecture
MVC architectureMVC architecture
MVC architecture
 
MVVM - Model View ViewModel
MVVM - Model View ViewModelMVVM - Model View ViewModel
MVVM - Model View ViewModel
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
 
Mvc pattern and implementation in java fair
Mvc   pattern   and implementation   in   java fairMvc   pattern   and implementation   in   java fair
Mvc pattern and implementation in java fair
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
 
Introduction to mvc architecture
Introduction to mvc architectureIntroduction to mvc architecture
Introduction to mvc architecture
 
Why Use MVC?
Why Use MVC?Why Use MVC?
Why Use MVC?
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
 

Similar to Ui design patterns

реалии использования Mv в i os разработке
реалии использования Mv в i os разработкереалии использования Mv в i os разработке
реалии использования Mv в i os разработке
Provectus
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
Boulos Dib
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernatebwullems
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
Caleb Jenkins
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
Edureka!
 
UI Design Patterns
UI Design PatternsUI Design Patterns
UI Design Patterns
aamiralihussain
 
Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01Jennie Gajjar
 
MVVM and Prism
MVVM and PrismMVVM and Prism
MVVM and Prism
Bilal Ahmed
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshop
Jorge Ortiz
 
Ios models
Ios modelsIos models
Ios models
JUDYFLAVIAB
 
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
 
Thin Controllers Fat Models - How to Write Better Code
Thin Controllers Fat Models - How to Write Better CodeThin Controllers Fat Models - How to Write Better Code
Thin Controllers Fat Models - How to Write Better Code
Dr. Syed Hassan Amin
 
Which is better asp.net mvc vs asp.net
Which is better  asp.net mvc vs asp.netWhich is better  asp.net mvc vs asp.net
Which is better asp.net mvc vs asp.net
Concetto Labs
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
Jitendra Kumar
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
Qamar Abbas
 
Models used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMModels used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVM
Andrei Popa
 
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
 
MVP Clean Architecture
MVP Clean  Architecture MVP Clean  Architecture
MVP Clean Architecture
Himanshu Dudhat
 

Similar to Ui design patterns (20)

реалии использования Mv в i os разработке
реалии использования Mv в i os разработкереалии использования Mv в i os разработке
реалии использования Mv в i os разработке
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernate
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
 
UI Design Patterns
UI Design PatternsUI Design Patterns
UI Design Patterns
 
Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01Mvc 130330091359-phpapp01
Mvc 130330091359-phpapp01
 
MVVM and Prism
MVVM and PrismMVVM and Prism
MVVM and Prism
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshop
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Ios models
Ios modelsIos models
Ios models
 
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
 
Thin Controllers Fat Models - How to Write Better Code
Thin Controllers Fat Models - How to Write Better CodeThin Controllers Fat Models - How to Write Better Code
Thin Controllers Fat Models - How to Write Better Code
 
Which is better asp.net mvc vs asp.net
Which is better  asp.net mvc vs asp.netWhich is better  asp.net mvc vs asp.net
Which is better asp.net mvc vs asp.net
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
 
Models used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMModels used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVM
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
 
MVP Clean Architecture
MVP Clean  Architecture MVP Clean  Architecture
MVP Clean Architecture
 

More from Jorge Ortiz

Fiscalidad en el app store 2014
Fiscalidad en el app store 2014Fiscalidad en el app store 2014
Fiscalidad en el app store 2014Jorge Ortiz
 
Fiscalidad en el app store 2014
Fiscalidad en el app store 2014Fiscalidad en el app store 2014
Fiscalidad en el app store 2014
Jorge Ortiz
 
Automatización de interfaces e introducción a bdd
Automatización de interfaces e introducción a bddAutomatización de interfaces e introducción a bdd
Automatización de interfaces e introducción a bdd
Jorge Ortiz
 
Multipeer Connectivity Framework
Multipeer Connectivity FrameworkMultipeer Connectivity Framework
Multipeer Connectivity Framework
Jorge Ortiz
 
iBeacons
iBeaconsiBeacons
iBeacons
Jorge Ortiz
 
Kata tdd
Kata tddKata tdd
Kata tdd
Jorge Ortiz
 
Autolayout
AutolayoutAutolayout
Autolayout
Jorge Ortiz
 
Crashlitycs
CrashlitycsCrashlitycs
Crashlitycs
Jorge Ortiz
 
¿Cuánto cuesta una app?
¿Cuánto cuesta una app?¿Cuánto cuesta una app?
¿Cuánto cuesta una app?
Jorge Ortiz
 
Aplicaciones para iphone accesibles
Aplicaciones para iphone accesiblesAplicaciones para iphone accesibles
Aplicaciones para iphone accesiblesJorge Ortiz
 
Introduccion a core plot
Introduccion a core plotIntroduccion a core plot
Introduccion a core plot
Jorge Ortiz
 

More from Jorge Ortiz (12)

Fiscalidad en el app store 2014
Fiscalidad en el app store 2014Fiscalidad en el app store 2014
Fiscalidad en el app store 2014
 
Fiscalidad en el app store 2014
Fiscalidad en el app store 2014Fiscalidad en el app store 2014
Fiscalidad en el app store 2014
 
Automatización de interfaces e introducción a bdd
Automatización de interfaces e introducción a bddAutomatización de interfaces e introducción a bdd
Automatización de interfaces e introducción a bdd
 
Multipeer Connectivity Framework
Multipeer Connectivity FrameworkMultipeer Connectivity Framework
Multipeer Connectivity Framework
 
iBeacons
iBeaconsiBeacons
iBeacons
 
Kata tdd
Kata tddKata tdd
Kata tdd
 
Autolayout
AutolayoutAutolayout
Autolayout
 
Crashlitycs
CrashlitycsCrashlitycs
Crashlitycs
 
¿Cuánto cuesta una app?
¿Cuánto cuesta una app?¿Cuánto cuesta una app?
¿Cuánto cuesta una app?
 
Runtime
RuntimeRuntime
Runtime
 
Aplicaciones para iphone accesibles
Aplicaciones para iphone accesiblesAplicaciones para iphone accesibles
Aplicaciones para iphone accesibles
 
Introduccion a core plot
Introduccion a core plotIntroduccion a core plot
Introduccion a core plot
 

Recently uploaded

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 

Recently uploaded (20)

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 

Ui design patterns

  • 1. UI Design Patterns Jorge D. Ortiz Fuentes PoWWaU
  • 2. Agenda ★Context on design patterns ★MVC ★MVP ★MVVM ★Lessons Learned 2
  • 4. Disclaimer ★Not an expert ★Lack of code here ★Opinionated 4
  • 5. Some assumptions ★Core Data for persistence ★As few external dependencies as possible (i.e., no Reactive Cocoa) ★Examples referred to iOS. (Many similarities with OS X, but some differences too) 5
  • 6. Design Patterns ★Predefined solutions to common problems with additional benefits: ๏Reusable ๏Loosely coupled ★Some examples: ๏Singleton ๏Delegate ๏Observer 6
  • 7. Defining a design pattern 1. Name 2. Problem 3. Solution 4. Consequences 7
  • 9. "Different people reading about MVC in different places take different ideas from it and describe these as 'MVC'. If this doesn't cause enough confusion you then get the effect of misunderstandings of MVC that develop through a system of Chinese whispers.” Martin Fowler Painful truth
  • 10. A tricky question If [Model] + [View] + [Controller / Presenter / View Model] = [TheApp] How can Controller != Presenter ! = View Model? ★Responsibilities matter! ★Other components (patterns) might be involved. 10
  • 11. The goal ★Separation of responsibilities into roles. Is it? Not historically. Other motivations. Solving problem d’jour. ★Now why? ๏Testability ๏Reusability ๏Extensibility 11
  • 12. Responsibilities ★Handle low level events ★Handle high level events ★Update user interface ★Apply changes to the domain model ★Presentation logic ★More… 12
  • 14. MVC: The early days ★View ๏Visual representation of the model ๏Receives references to the model to know the data to display. (Not too reusable views) ★Controller ๏Deals with user input, app <-> human (old paradigmas) ๏Shows the widgets change and tell the model what to do. ★Model ๏Data and business functionality (domain). ๏No references to the UI. ๏It is observable. ๏Display logic is part of the model. Ctrlr ModelView
  • 15. MVC: The early days ★Separated presentation: Model <-> Presentation (= V+C) ★Observer originated from MVC, but observing full object (properties = scalars) ★Variations: Passive model The model cannot send updates (for example HTTP) 15
  • 17. Apple’s MVC ★View ๏Only UIView subclasses ๏Show information and handle input to generate higher level events passed to controller ๏Fully reusable views library. Consistent L&F ★Controller ๏Views delegate / control what’s displayed ๏Receive the events and converts them into calls to the model. ๏_Knows_ about changes in the model and update what is displayed on the view. Typically a UIViewController. Responsible of presentation logic. ★Model ๏Contain the business logic. No references to the UI. Flow synchronization vs Observer synchronization MVC = Composite + Strategy + Observer Ctrlr ModelView
  • 18. MVC Code Distribution ★Model: ๏NSManagedObjectModel, NSPersistentStore, NSPersistentCoordinator, NSManagedObjectContext ๏NSManagedObject subclasses and its categories (or additional methods) ๏UIManagedDocument ๏NSFetchRequests ★Controller: ๏Theme ๏Observer ๏Targets/selectors for the views actions ๏View delegates ๏Presentation logic ๏NSFetchedResultsControlle r ★Views: ๏UIButton, UILabel, UITableView...
  • 19. Apple’s MVC: testability ★The views are somebody else's (Apple's) problem. ★Model is easy to test. ★Controller is huge & has dependencies on the model and on the views. => Complex to test. ★Too many levels of abstraction, only a few methods exposed. ★Some stuff in view controller that it is usually not tested. 19
  • 20. MVP
  • 21. MVP Origin: IBM & Taligent (=IBM + Apple) ★View ๏Shows information and process the input gestures transferring control to the presenter. ๏View is updated using the observer pattern. ★Presenter ๏Respond to high level events (user acts) ๏Generates commands (Command pattern) for the model. (Easy undo redo) ★Model ๏Receives the commands and acts on the domain information Prstr CmdsInteract ModelView Selec
  • 22. MVP Code Distribution ★Model: ๏NSManagedObjectModel, NSPersistentStore, NSPersistentCoordinator, NSManagedObjectContext, & UIManagedDocument ๏NSManagedObject subclasses and its categories (or additional methods). ๏NSFetchRequests ★Selections: ๏NSFetchedResultsController ★Commands: ๏NSInvocation / NSUndoManager ★Presenter: ๏Observer ๏Targets/selectors for the views actions & View delegates. ๏Presentation logic ๏View controller ★Interactors: ๏Gesture recognizers ★Views: ๏UIButton, UILabel…
  • 23. MVP testability ★Apple's MVC is closer to this than to classic MVC (Even more compared to the Dolphin MVP). ★View Controller belongs with the view. ★Properties are now objects, instead of scalars, so observation is per property. Easier to deal with indirect invocations. ★More parts, more difficult to write, but easier to test and reuse. ★If model uses Core Data the command pattern is almost there (undo/redo). 23
  • 24. MVVM
  • 25. MVVM ★View ๏Shows information and process the input gestures transferring control to the presenter ๏View is updated using the observer pattern. View + View Controller ๏Responsible for display logic, themes... ★View Model ๏Respond to high level events (user acts) Provides calls to the View (invoked via the view controller) ๏Validation logic. ★Model ๏Receives the commands and acts on the domain information VM VC ModelView
  • 26. MVVM Testability ★The view controller is conceptually attached to the view role. ★The View Model would be the same for different platforms, since there isn't any specific mention of the views. ★Presentation logic (like formatting strings) belongs to the model. Easier to test exposed methods. ★MVVM is the E&E (embrace and extend) version of MVP. ★Data binding is NOT a key difference. ★Rx programming claim increased testability: ๏doesn't need shared mutable state ๏can be composed ๏no callback hell. 26
  • 27. MVVM Code Distribution ★Model: ๏NSManagedObjectModel, NSPersistentStore, NSPersistentCoordinator, NSManagedObjectContext, & UIManagedDocument ๏NSManagedObject subclasses and its categories (or additional methods). ๏NSFetchRequests ★View Model: ๏NSFetchedResultsController ๏Observer ๏Targets/selectors for the views actions & View delegates. ๏Presentation logic ๏NSInvocation / NSUndoManager ★Views: ๏UIButton, UILabel… ๏View controller ๏Gesture recognizers
  • 29. Lessons Learned ★Same name used for different patterns. ★Good to understand patterns for your business (& mental health). ★A range of possibilities = trade offs. 29
  • 30. References ★Alfonso Alba García “Bienvenido a la república independiente de las pruebas unitarias con Core Data”, 2013
 http://es.slideshare.net/ aalbagarcia/bienvenido-a-la- republica-independiente ★The Gang of 4, “Design Patterns: Elements of Reusable Object-Oriented Software”, 1994 ★Derek Greer “Interactive Application Architecture Patterns”, 2007
 http://aspiringcraftsman.com/ 2007/08/25/interactive- application-architecture/ ★Martin Fowler, "Patterns of Enterprise Application Architecture”, 2002 ★Martin Fowler, “GUI Architectures”, 2006
 http://martinfowler.com/ eaaDev/uiArchs.html ★Ash Furrow “Model-View- ViewModel for iOS”, 2014
 http://www.teehanlax.com/ blog/model-view-viewmodel- for-ios/