@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

PDF
MobileAppDev Handout#1
PPTX
API Strategy & Practice Conference - API Consumption from the Hackathon Trenches
PDF
apidays LIVE Australia 2021 - The big rebundling in financial services: threa...
PDF
PDF
INTERFACE, by apidays - Building an API-First organization by Ankit Sobti, P...
PDF
I beacon mobile_tea
PDF
Big data and mobile
PDF
The Little Shop of TDD Horrors
MobileAppDev Handout#1
API Strategy & Practice Conference - API Consumption from the Hackathon Trenches
apidays LIVE Australia 2021 - The big rebundling in financial services: threa...
INTERFACE, by apidays - Building an API-First organization by Ankit Sobti, P...
I beacon mobile_tea
Big data and mobile
The Little Shop of TDD Horrors

Viewers also liked (11)

PDF
Service worker API
PPTX
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
PDF
Mobile benchmarking-and-profiling
PDF
Test first
PDF
Android, getting started
PDF
Application architecture doesn't have to suck
PDF
Clean architecture workshop
PDF
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
PDF
Making your washing machine talk with a power plant
PPTX
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
PPTX
iOS Coding Best Practices
Service worker API
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Mobile benchmarking-and-profiling
Test first
Android, getting started
Application architecture doesn't have to suck
Clean architecture workshop
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
Making your washing machine talk with a power plant
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
iOS Coding Best Practices
Ad

Similar to Clear the UIViewController Mess (20)

PPTX
VIPER Architecture
DOCX
Minor Project Final Report
PDF
Application for Data Sync Between Different geo Locations
PDF
Robotic Virtual Telepresence with Raspberry pi
PPT
Case study on tablet application for real time video, audio and ppt conversion
PDF
Real-time Text Audio to Video PPT Converter Tablet App
PDF
Password security system for websites
PDF
Building Mobile Apps With jQuery For Any Device In The Cloud
KEY
Jonathan snook - fake-it
PPTX
MVVM ( Model View ViewModel )
PDF
Virtual Automation using Mixed Reality and Leap Motion Control
PDF
FIWARE Global Summit - Empowering and Enhancing IoT Agent for Device Manageme...
PDF
Introduction To MVVM
DOCX
Siebel connected mobile applications an overview
PPTX
IoT Basics, current trends, the future
PPTX
Sudip_Internship[1].pptxgghhjjgggggggghg
PPTX
MVVM Design Pattern NDC2009
PPTX
Secured Augmented Reality for IoT Devices Management.pptx
PDF
Task 2 - Educational Article – Model View Controller (MVC)
PDF
Future Smart UI UX Insights from Patents Implementing Minority Report
VIPER Architecture
Minor Project Final Report
Application for Data Sync Between Different geo Locations
Robotic Virtual Telepresence with Raspberry pi
Case study on tablet application for real time video, audio and ppt conversion
Real-time Text Audio to Video PPT Converter Tablet App
Password security system for websites
Building Mobile Apps With jQuery For Any Device In The Cloud
Jonathan snook - fake-it
MVVM ( Model View ViewModel )
Virtual Automation using Mixed Reality and Leap Motion Control
FIWARE Global Summit - Empowering and Enhancing IoT Agent for Device Manageme...
Introduction To MVVM
Siebel connected mobile applications an overview
IoT Basics, current trends, the future
Sudip_Internship[1].pptxgghhjjgggggggghg
MVVM Design Pattern NDC2009
Secured Augmented Reality for IoT Devices Management.pptx
Task 2 - Educational Article – Model View Controller (MVC)
Future Smart UI UX Insights from Patents Implementing Minority Report
Ad

More from Giorgio Natili (14)

PDF
Driving Assistant Solutions with Android
PDF
Isomorphic Reactive Programming
PDF
The short path to ecma 6
PDF
Jasmine 2.0
PDF
Harmonik
PDF
Mobile raspberry pi
PDF
WebRTC communication and wearable devices
PDF
Multithreading development with workers
PDF
Ecma6 in 30 minutes
PDF
TDD and PhoneGap
PDF
Undoable architectures
PDF
Test first!
PDF
WebRTC and Mobile Integration
PDF
Develop, test and debug cross platforms apps with PhoneGap
Driving Assistant Solutions with Android
Isomorphic Reactive Programming
The short path to ecma 6
Jasmine 2.0
Harmonik
Mobile raspberry pi
WebRTC communication and wearable devices
Multithreading development with workers
Ecma6 in 30 minutes
TDD and PhoneGap
Undoable architectures
Test first!
WebRTC and Mobile Integration
Develop, test and debug cross platforms apps with PhoneGap

Recently uploaded (9)

PDF
2025 Guide to Buy Verified Cash App Accounts You Can Trust.pdf
PPTX
Social Media People PowerPoint Templates.pptx
DOC
EIU毕业证学历认证,贝尔维尤学院毕业证国外毕业证
PDF
Date Right Stuff - Invite only, conservative dating app
PPTX
Introduction to Packet Tracer Course Overview - Aug 21 (1).pptx
PDF
Best 4 Sites for Buy Verified Cash App Accounts – BTC Only.pdf
DOC
NIU毕业证学历认证,阿比林基督大学毕业证留学生学历
DOC
SIUE毕业证学历认证,阿祖萨太平洋大学毕业证学位证书复制
PDF
Kids, Screens & Emotional Development by Meenakshi Khakat
2025 Guide to Buy Verified Cash App Accounts You Can Trust.pdf
Social Media People PowerPoint Templates.pptx
EIU毕业证学历认证,贝尔维尤学院毕业证国外毕业证
Date Right Stuff - Invite only, conservative dating app
Introduction to Packet Tracer Course Overview - Aug 21 (1).pptx
Best 4 Sites for Buy Verified Cash App Accounts – BTC Only.pdf
NIU毕业证学历认证,阿比林基督大学毕业证留学生学历
SIUE毕业证学历认证,阿祖萨太平洋大学毕业证学位证书复制
Kids, Screens & Emotional Development by Meenakshi Khakat

Clear the UIViewController Mess