SlideShare a Scribd company logo
1 of 21
Download to read offline
@giorgionatili#MobileTea
Clean up
the MVW
mess
a journey into the abomination of MVC
architecture on iOS
@giorgionatili#MobileTea
Who am I?
Technical Leader and Agile Coach·
Front-end Developer (test first!)
Mobile Developer (iOS, Android, Hybrid with Cordova, c++)
Organizer of Mobile Tea and New England Software
Engineer meetups
Mobile and devices instructor at General Assembly
the mobile dude!
@giorgionatili#MobileTea
on
stage
The
UIViewController
spaghetti monster
The invincible
delegates
The wild segues
for tonight only!
NO.1
@giorgionatili#MobileTea
It's not our fault!
Someone else
designed the
framework!
@giorgionatili#MobileTea
SmallTalk MVC
courtesy of http://hollance.github.io/
@giorgionatili#MobileTea
iOS MVC
courtesy of http://hollance.github.io/
@giorgionatili#MobileTea
Architecturehorrors!
What’s Wrong with This?
Controllers are not
just controllers (the
class name should
suggest this)
Controllers are to
much tied in the view
(aka IBAction and
IBOutlet)
UI element s are
configured in the
viewDidLoad
Location services,
map services, etc. are
normally used in the
controller (delegates
arena)
@giorgionatili#MobileTea
Xcode Defaults
The workflow of the
interface builder brings
you to do a mess!
With IBOutlet how can we
resist to configuring UI
items in the viewDidLoad?
How can we resist to
configuring segues in the
interface builder?
@giorgionatili#MobileTea
Why sucKh a Poor Design?
speeds up the development
decreases the learning curve
reduces the amount of code to write
More often misused and sometimes
abused, however:
@giorgionatili#MobileTea
But the architects
were right!
@giorgionatili#MobileTea
...we still can
clean up the mess!
@giorgionatili#MobileTea
Cleaning Side Effects
97%
43%
Reduced size of controllers, improved testability, increased
code base
code will
increase
@giorgionatili#MobileTea
VIPER
DECOUPLING LOGIC
FROM UI



PROPER DATA HANDLING



REUSABLE CODE



PONSOS



ALL WELCOME!
SPLIT INMULTIPLELAYERS
View
Interactor
Presenter
Entity
Routing
CLI support
http://bit.ly/
viper-ios
@giorgionatili#MobileTea
View
Handle events invoking presenter’s methods
Exposes a very precise interface completely UI
agnostic
The view is passive, it waits the presenter to render
data
It’s no longer a Mess
View Controller
UI items configuration
is now delegated to
UIView subclasses
@giorgionatili#MobileTea
Interactor
represents a single use case in the app
contains the logic to manipulate entities (local
and remote)
communicate with the view through the presenter
It’s a wrapper around the
data communication layer
Business logic is not
anymore in the
controller
@giorgionatili#MobileTea
Presenter
gathers user input and send the request to the
interactor
Receives results from the interactor as simple data
structures
Updates the view
Orchestrates the
communication and
business logic
The controller logic is
now completely
decoupled
@giorgionatili#MobileTea
Entity(ies)
It’s a model object manipulated by the interactor
An entity is never passed around the app
The entities are simple
and maintainable
CoreData, services, etc.
are no longer mixed up
with the view
@giorgionatili#MobileTea
Routing
handles navigation from one view to another
owns the UIWindow and installs the
view(controller) in the window
knows how to react to presenter “signals”
Communication handled
through NotificationCenter and
Key-Value Observing
Segues and present/push
VierController(s) are not
anymore in the view
@giorgionatili#MobileTea
Files Structure
.objc
+-- DataManager
| +-- VIPERDataManager.h
| +-- VIPERDataManager.m
+-- Interactor
| +-- VIPERInteractor.h
| +-- VIPERInteractor.m
+-- Presenter
| +-- VIPERPresenter.h
| +-- VIPERPresenter.m
+-- ViewController
| +-- VIPERViewController.h
| +-- VIPERViewController.m
+-- WireFrame
| +-- VIPERWireFrame.h
| +-- VIPERWireFrame.m
+-- Protocols
| +-- VIPERProtocols.h
swift
+-- DataManager
| +-- VIPERDataManager.swift
+-- Interactor
| +-- VIPERInteractor.swift
+-- Presenter
| +-- VIPERPresenter.swift
+-- ViewController
| +-- VIPERViewController.swift
+-- WireFrame
| +-- VIPERWireFrame.swift
+-- Protocols
| +-- VIPERProtocols.swift
@giorgionatili#MobileTea
@giorgionatili#MobileTea
Q and A

More Related Content

Viewers also liked

Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad NicheTech Com. Solutions Pvt. Ltd.
 
Mobile benchmarking-and-profiling
Mobile benchmarking-and-profilingMobile benchmarking-and-profiling
Mobile benchmarking-and-profilingGiorgio Natili
 
Android, getting started
Android, getting startedAndroid, getting started
Android, getting startedGiorgio Natili
 
Application architecture doesn't have to suck
Application architecture doesn't have to suckApplication architecture doesn't have to suck
Application architecture doesn't have to suckjtregunna
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshopJorge Ortiz
 
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015Matteo Collina
 
Making your washing machine talk with a power plant
Making your washing machine talk with a power plantMaking your washing machine talk with a power plant
Making your washing machine talk with a power plantMatteo Collina
 
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSSoftware architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSJinkyu Kim
 
iOS Coding Best Practices
iOS Coding Best PracticesiOS Coding Best Practices
iOS Coding Best PracticesJean-Luc David
 

Viewers also liked (11)

Service worker API
Service worker APIService worker API
Service worker API
 
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
 
Mobile benchmarking-and-profiling
Mobile benchmarking-and-profilingMobile benchmarking-and-profiling
Mobile benchmarking-and-profiling
 
Test first
Test firstTest first
Test first
 
Android, getting started
Android, getting startedAndroid, getting started
Android, getting started
 
Application architecture doesn't have to suck
Application architecture doesn't have to suckApplication architecture doesn't have to suck
Application architecture doesn't have to suck
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshop
 
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
 
Making your washing machine talk with a power plant
Making your washing machine talk with a power plantMaking your washing machine talk with a power plant
Making your washing machine talk with a power plant
 
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
 
iOS Coding Best Practices
iOS Coding Best PracticesiOS Coding Best Practices
iOS Coding Best Practices
 

Similar to Clear the UIViewController Mess

VIPER Architecture
VIPER ArchitectureVIPER Architecture
VIPER ArchitectureAhmed Lotfy
 
Minor Project Final Report
Minor Project Final ReportMinor Project Final Report
Minor Project Final ReportYogesh Madaan
 
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
 
Robotic Virtual Telepresence with Raspberry pi
Robotic Virtual Telepresence with Raspberry piRobotic Virtual Telepresence with Raspberry pi
Robotic Virtual Telepresence with Raspberry piIRJET Journal
 
Case study on tablet application for real time video, audio and ppt conversion
Case study on tablet application for real time video, audio and ppt conversionCase study on tablet application for real time video, audio and ppt conversion
Case study on tablet application for real time video, audio and ppt conversionGrey Matter India Technologies PVT LTD
 
Real-time Text Audio to Video PPT Converter Tablet App
Real-time Text Audio to Video PPT Converter Tablet AppReal-time Text Audio to Video PPT Converter Tablet App
Real-time Text Audio to Video PPT Converter Tablet AppMike Taylor
 
Password security system for websites
Password security system for websitesPassword security system for websites
Password security system for websitesMike Taylor
 
Building Mobile Apps With jQuery For Any Device In The Cloud
Building Mobile Apps With jQuery For Any Device In The Cloud Building Mobile Apps With jQuery For Any Device In The Cloud
Building Mobile Apps With jQuery For Any Device In The Cloud Max Katz
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
Virtual Automation using Mixed Reality and Leap Motion Control
Virtual Automation using Mixed Reality and Leap Motion ControlVirtual Automation using Mixed Reality and Leap Motion Control
Virtual Automation using Mixed Reality and Leap Motion ControlIRJET Journal
 
FIWARE Global Summit - Empowering and Enhancing IoT Agent for Device Manageme...
FIWARE Global Summit - Empowering and Enhancing IoT Agent for Device Manageme...FIWARE Global Summit - Empowering and Enhancing IoT Agent for Device Manageme...
FIWARE Global Summit - Empowering and Enhancing IoT Agent for Device Manageme...FIWARE
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVMBoulos Dib
 
Siebel connected mobile applications an overview
Siebel connected mobile applications   an overviewSiebel connected mobile applications   an overview
Siebel connected mobile applications an overviewsnuthakki
 
IoT Basics, current trends, the future
IoT Basics, current trends, the futureIoT Basics, current trends, the future
IoT Basics, current trends, the futureCharalampos Doukas
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009Jonas Follesø
 
Secured Augmented Reality for IoT Devices Management.pptx
Secured Augmented Reality for IoT Devices Management.pptxSecured Augmented Reality for IoT Devices Management.pptx
Secured Augmented Reality for IoT Devices Management.pptxSubburaj51
 
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
 
Future Smart UI UX Insights from Patents Implementing Minority Report
Future Smart UI UX Insights from Patents Implementing Minority ReportFuture Smart UI UX Insights from Patents Implementing Minority Report
Future Smart UI UX Insights from Patents Implementing Minority ReportAlex G. Lee, Ph.D. Esq. CLP
 
Case study on Movie Quiz App For IPhone and IPad – Facebook Enabled
Case study on Movie Quiz App For IPhone and IPad –  Facebook Enabled Case study on Movie Quiz App For IPhone and IPad –  Facebook Enabled
Case study on Movie Quiz App For IPhone and IPad – Facebook Enabled Grey Matter India Technologies PVT LTD
 

Similar to Clear the UIViewController Mess (20)

VIPER Architecture
VIPER ArchitectureVIPER Architecture
VIPER Architecture
 
Minor Project Final Report
Minor Project Final ReportMinor Project Final Report
Minor Project Final Report
 
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
 
Robotic Virtual Telepresence with Raspberry pi
Robotic Virtual Telepresence with Raspberry piRobotic Virtual Telepresence with Raspberry pi
Robotic Virtual Telepresence with Raspberry pi
 
Case study on tablet application for real time video, audio and ppt conversion
Case study on tablet application for real time video, audio and ppt conversionCase study on tablet application for real time video, audio and ppt conversion
Case study on tablet application for real time video, audio and ppt conversion
 
Real-time Text Audio to Video PPT Converter Tablet App
Real-time Text Audio to Video PPT Converter Tablet AppReal-time Text Audio to Video PPT Converter Tablet App
Real-time Text Audio to Video PPT Converter Tablet App
 
Password security system for websites
Password security system for websitesPassword security system for websites
Password security system for websites
 
Building Mobile Apps With jQuery For Any Device In The Cloud
Building Mobile Apps With jQuery For Any Device In The Cloud Building Mobile Apps With jQuery For Any Device In The Cloud
Building Mobile Apps With jQuery For Any Device In The Cloud
 
Jonathan snook - fake-it
Jonathan snook - fake-itJonathan snook - fake-it
Jonathan snook - fake-it
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
Virtual Automation using Mixed Reality and Leap Motion Control
Virtual Automation using Mixed Reality and Leap Motion ControlVirtual Automation using Mixed Reality and Leap Motion Control
Virtual Automation using Mixed Reality and Leap Motion Control
 
FIWARE Global Summit - Empowering and Enhancing IoT Agent for Device Manageme...
FIWARE Global Summit - Empowering and Enhancing IoT Agent for Device Manageme...FIWARE Global Summit - Empowering and Enhancing IoT Agent for Device Manageme...
FIWARE Global Summit - Empowering and Enhancing IoT Agent for Device Manageme...
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
 
Siebel connected mobile applications an overview
Siebel connected mobile applications   an overviewSiebel connected mobile applications   an overview
Siebel connected mobile applications an overview
 
IoT Basics, current trends, the future
IoT Basics, current trends, the futureIoT Basics, current trends, the future
IoT Basics, current trends, the future
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
 
Secured Augmented Reality for IoT Devices Management.pptx
Secured Augmented Reality for IoT Devices Management.pptxSecured Augmented Reality for IoT Devices Management.pptx
Secured Augmented Reality for IoT Devices Management.pptx
 
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)
 
Future Smart UI UX Insights from Patents Implementing Minority Report
Future Smart UI UX Insights from Patents Implementing Minority ReportFuture Smart UI UX Insights from Patents Implementing Minority Report
Future Smart UI UX Insights from Patents Implementing Minority Report
 
Case study on Movie Quiz App For IPhone and IPad – Facebook Enabled
Case study on Movie Quiz App For IPhone and IPad –  Facebook Enabled Case study on Movie Quiz App For IPhone and IPad –  Facebook Enabled
Case study on Movie Quiz App For IPhone and IPad – Facebook Enabled
 

More from Giorgio Natili

Driving Assistant Solutions with Android
Driving Assistant Solutions with AndroidDriving Assistant Solutions with Android
Driving Assistant Solutions with AndroidGiorgio Natili
 
Isomorphic Reactive Programming
Isomorphic Reactive ProgrammingIsomorphic Reactive Programming
Isomorphic Reactive ProgrammingGiorgio Natili
 
The short path to ecma 6
The short path to ecma 6The short path to ecma 6
The short path to ecma 6Giorgio Natili
 
WebRTC communication and wearable devices
WebRTC communication and wearable devicesWebRTC communication and wearable devices
WebRTC communication and wearable devicesGiorgio Natili
 
Multithreading development with workers
Multithreading development with workersMultithreading development with workers
Multithreading development with workersGiorgio Natili
 
Undoable architectures
Undoable architecturesUndoable architectures
Undoable architecturesGiorgio Natili
 
WebRTC and Mobile Integration
WebRTC and Mobile IntegrationWebRTC and Mobile Integration
WebRTC and Mobile IntegrationGiorgio Natili
 
Develop, test and debug cross platforms apps with PhoneGap
Develop, test and debug cross platforms apps with PhoneGapDevelop, test and debug cross platforms apps with PhoneGap
Develop, test and debug cross platforms apps with PhoneGapGiorgio Natili
 

More from Giorgio Natili (14)

Driving Assistant Solutions with Android
Driving Assistant Solutions with AndroidDriving Assistant Solutions with Android
Driving Assistant Solutions with Android
 
Isomorphic Reactive Programming
Isomorphic Reactive ProgrammingIsomorphic Reactive Programming
Isomorphic Reactive Programming
 
The short path to ecma 6
The short path to ecma 6The short path to ecma 6
The short path to ecma 6
 
Jasmine 2.0
Jasmine 2.0Jasmine 2.0
Jasmine 2.0
 
Harmonik
HarmonikHarmonik
Harmonik
 
Mobile raspberry pi
Mobile raspberry piMobile raspberry pi
Mobile raspberry pi
 
WebRTC communication and wearable devices
WebRTC communication and wearable devicesWebRTC communication and wearable devices
WebRTC communication and wearable devices
 
Multithreading development with workers
Multithreading development with workersMultithreading development with workers
Multithreading development with workers
 
Ecma6 in 30 minutes
Ecma6 in 30 minutesEcma6 in 30 minutes
Ecma6 in 30 minutes
 
TDD and PhoneGap
TDD and PhoneGapTDD and PhoneGap
TDD and PhoneGap
 
Undoable architectures
Undoable architecturesUndoable architectures
Undoable architectures
 
Test first!
Test first!Test first!
Test first!
 
WebRTC and Mobile Integration
WebRTC and Mobile IntegrationWebRTC and Mobile Integration
WebRTC and Mobile Integration
 
Develop, test and debug cross platforms apps with PhoneGap
Develop, test and debug cross platforms apps with PhoneGapDevelop, test and debug cross platforms apps with PhoneGap
Develop, test and debug cross platforms apps with PhoneGap
 

Recently uploaded

Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPsychicRuben LoveSpells
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRnishacall1
 
Leading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdfLeading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdfCWS Technology
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Servicenishacall1
 

Recently uploaded (6)

Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
 
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
 
Leading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdfLeading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdf
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
 
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
 

Clear the UIViewController Mess