SlideShare a Scribd company logo
from MVC to VIPER 
Krzysztof Profic 
@kprofic
Legacy codebase 
Better codebase
Pragmatic approach 
what hurts my eyes?
Pragmatic approach 
what hurts my eyes? 
UIViewController
Massive 
UIViewController
4 Steps 
• MVC on diet 
• MVVM 
• Intentions 
• VIPER
4 Steps 
• MVC on diet 
• MVVM 
• Intentions 
• VIPER
MVC on diet 
Massive View Controller 
Light View Controller
Reducing 
Massive ViewController 
• extract datasource 
• move domain logic into the model 
• move view code into the view layer 
objc.io #1
Reducing 
Massive ViewController 
• extract datasource 
• move domain logic into the model 
• move view code into the view layer 
objc.io #1
Reducing 
Massive ViewController 
• extract datasource 
• move domain logic into the model 
• move view code into the view layer 
objc.io #1
Reducing 
Massive ViewController 
• Separation of concerns 
• Single responsibility principle 
objc.io #1
Reanimate your MVC 
reduce MVC principles violation 
put ViewController on a diet
What is the Rule?
“Keep the code where 
it belongs”
Layer
From mvc to viper
From mvc to viper
Controllers 
Use Cases 
Entities 
Presenters 
Gateways 
UI 
DB 
External 
Interfaces 
Devices 
The Clean Architecture 
Enterprise Business Rules 
Application Business Rules 
Interface Adapters 
Frameworks & Drivers 
Web 
Controller 
Use Case 
Interactor 
Presenter 
Use Case 
Output Port 
Use Case 
Input Port 
Flow of control 
<I> 
<I> 
http://blog.8thlight.com
separation of concerns = dividing software into … 
Layers
“Keep the code on 
the right layer”
The Dependency Rule
Controllers 
Use Cases 
Entities 
Presenters 
Gateways 
UI 
DB 
External 
Interfaces 
Devices 
The Clean Architecture 
Enterprise Business Rules 
Application Business Rules 
Interface Adapters 
Frameworks & Drivers 
Web 
Controller 
Use Case 
Interactor 
Presenter 
Use Case 
Output Port 
Use Case 
Input Port 
Flow of control 
<I> 
<I> 
http://blog.8thlight.com
MVC variation
MVC variation
MVVM
4 Steps 
• MVC on diet 
• MVVM 
• Intentions 
• VIPER
Let’s talk code
- (void)viewDidLoad { 
[super viewDidLoad]; 
if (self.model.salutation.length > 0) { 
self.nameLabel.text = [NSString stringWithFormat:@"%@ %@ %@“, 
self.model.salutation, 
self.model.firstName, 
self.model.lastName]; 
} else { 
self.nameLabel.text = [NSString stringWithFormat:@"%@ %@“, 
self.model.firstName, 
self.model.lastName]; 
} 
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
[dateFormatter setDateFormat:@"EEEE MMMM d, yyyy"]; 
self.birthdateLabel.text = [dateFormatter 
stringFromDate:model.birthdate]; 
} 
PersonViewController.m
@implementation PersonViewModel 
- (instancetype)initWithPerson:(Person *)person { 
self = [super init]; 
if (!self) return nil; 
_person = person; 
if (person.salutation.length > 0) { 
_nameText = [NSString stringWithFormat:@"%@ %@ %@“, 
self.person.salutation, 
self.person.firstName, self.person.lastName]; 
} else { 
_nameText = [NSString stringWithFormat:@"%@ %@", 
self.person.firstName, 
self.person.lastName]; 
} 
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
[dateFormatter setDateFormat:@"EEEE MMMM d, yyyy"]; 
_birthdateText = [dateFormatter 
stringFromDate:person.birthdate]; 
return self; 
} 
@end PersonViewModel.m
- (void)viewDidLoad { 
[super viewDidLoad]; 
self.nameLabel.text = self.viewModel.nameText; 
self.birthdateLabel.text = self.viewModel.birthdateText; 
} 
PersonViewController.m
4 Steps 
• MVC on diet 
• MVVM 
• Intentions 
• VIPER
Motivation 
• ViewController implements only viewWill* viewDid*
• encapsulate small pieces of business logic 
• use case approach (form validation, login user) 
• hookable via & 
• reusable 
Intentions 
Architecture is about Intent “Uncle Bob” 
IBOutlet IBAction
From mvc to viper
@interface ViewController () 
@property (strong) IBOutlet ModelContainer* modelContainer; 
@end 
@implementation ViewController 
- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
PersonViewModel * pvm = [[PersonViewModel alloc] 
initWithModel:self.person]; 
self.modelContainer.viewModel = pvm; 
} 
@end 
ViewController.m
Observing ViewModel
@interface ObserveIntention () 
@property (strong, nonatomic) IBOutlet id sourceObject; 
@property (strong, nonatomic) IBOutlet id target; 
@property (copy, nonatomic) IBOutlet NSString *sourceKeyPath; 
@property (copy, nonatomic) IBOutlet NSString *targetKeyPath; 
@end
@implementation ObserveIntention 
- (void)awakeFromNib { 
[super awakeFromNib]; 
[self updateValue]; 
[self.sourceObject addObserver:self 
forKeyPath:self.sourceKeyPath options:0 context:nil]; 
} 
- (void)updateValue { 
id value = [self.sourceObject valueForKeyPath: 
self.sourceKeyPath]; 
if (self.targetKeyPath) { 
[self.target setValue:value forKeyPath:self.targetKeyPath]; 
} 
} 
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)obj 
change:(NSDictionary *)change context:(void *)context { 
if ([keyPath isEqualToString:self.sourceKeyPath]) { 
[self updateValue]; 
} 
} 
@end
From mvc to viper
Behaviours 
UIControl 
objc.io #13
Login
User Story #90.10 - Login 
• A. When I as a user open the app the first time I 
enter the “main login” page, where I need to login 
with my username (email address) and password. 
• B. When I tap the “login button” while online and no 
errors occur I’m moved to initial page with users 
profile.
User Story #90.10 - Login 
• A. When I as a user open the app the first time I 
enter the “main login” page, where I need to login 
with my username (email address) and password. 
• B. When I tap the “login button” while online and 
no errors occur I’m moved to initial page with users 
profile.
From mvc to viper
@interface LoginIntention() 
@property (strong) IBOutlet UITextField * usernameTextField; 
@property (strong) IBOutlet UITextField * passwordTextField; 
@property (strong, nonatomic) IBOutlet UILabel * statusLabel; 
@end 
@implementation LoginIntention 
- (IBAction)login:(id)sender { 
self.statusLabel.text = @"connecting..."; 
[self sendActionsForControlEvents:UIControlEventValueChanged]; 
self.statusLabel.text = [NSString 
stringWithFormat:@"Authenticating %@“, 
self.usernameTextField.text]; 
[self sendActionsForControlEvents:UIControlEventValueChanged]; 
self.statusLabel.text = @"done"; 
[self sendActionsForControlEvents:UIControlEventValueChanged]; 
} 
@end 
LoginIntention.m
@implementation LoginViewController 
- (IBAction)loginIntentionStateChanged:(LoginIntention *)sender { 
if ([sender.statusLabel.text isEqualToString:@"done"]){ 
[self.presentingViewController 
dismissViewControllerAnimated:YES completion:nil]; 
} 
} 
@end 
LoginViewController.m
4 Steps 
• MVC on diet 
• MVVM 
• Intentions 
• VIPER
If you want more, checkout 
VIPER 
• View 
• Interactor 
• Presenter 
• Entity 
• Routing
Summary: 
MVC on diet 
MVVM 
Intentions / Behaviours 
VIPER
Thank you! 
Krzysztof Profic 
@kprofic
• http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean- 
architecture.html 
• http://www.scottlogic.com/blog/2014/05/11/ 
reactivecocoa-tableview-binding.html 
• http://chris.eidhof.nl/posts/intentions.html 
• http://www.objc.io/issue-13/behaviors.html 
• http://www.objc.io/issue-13/viper.html
Ad

More Related Content

What's hot (20)

Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginners
Munir Hoque
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
Tamer Solieman
 
Angular js presentation at Datacom
Angular js presentation at DatacomAngular js presentation at Datacom
Angular js presentation at Datacom
David Xi Peng Yang
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
Sathish VJ
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
Boyan Mihaylov
 
Rambler.iOS #5: Разбираем Massive View Controller
Rambler.iOS #5: Разбираем Massive View ControllerRambler.iOS #5: Разбираем Massive View Controller
Rambler.iOS #5: Разбираем Massive View Controller
RAMBLER&Co
 
5 angularjs features
5 angularjs features5 angularjs features
5 angularjs features
Alexey (Mr_Mig) Migutsky
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key Features
Mohamad Al Asmar
 
當ZK遇見Front-End
當ZK遇見Front-End當ZK遇見Front-End
當ZK遇見Front-End
祁源 朱
 
Design Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-BinderDesign Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-Binder
Simon Massey
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
Jennifer Estrada
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
Phan Tuan
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
Bipin
 
Angular js
Angular jsAngular js
Angular js
Behind D Walls
 
Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)Angular js architecture (v1.4.8)
Angular js architecture (v1.4.8)
Gabi Costel Lapusneanu
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
Sagar Acharya
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
Barry Gervin
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
Luigi De Russis
 
Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginners
Munir Hoque
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
Tamer Solieman
 
Angular js presentation at Datacom
Angular js presentation at DatacomAngular js presentation at Datacom
Angular js presentation at Datacom
David Xi Peng Yang
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
Sathish VJ
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
 
Rambler.iOS #5: Разбираем Massive View Controller
Rambler.iOS #5: Разбираем Massive View ControllerRambler.iOS #5: Разбираем Massive View Controller
Rambler.iOS #5: Разбираем Massive View Controller
RAMBLER&Co
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key Features
Mohamad Al Asmar
 
當ZK遇見Front-End
當ZK遇見Front-End當ZK遇見Front-End
當ZK遇見Front-End
祁源 朱
 
Design Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-BinderDesign Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-Binder
Simon Massey
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
Phan Tuan
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
Bipin
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
Sagar Acharya
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
Barry Gervin
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
Luigi De Russis
 

Viewers also liked (20)

VIPER - Design Pattern
VIPER - Design PatternVIPER - Design Pattern
VIPER - Design Pattern
Pedro Henrique Peralta
 
Rambler.iOS #5: VIPER и Swift
Rambler.iOS #5: VIPER и SwiftRambler.iOS #5: VIPER и Swift
Rambler.iOS #5: VIPER и Swift
RAMBLER&Co
 
Introduction to VIPER Architecture
Introduction to VIPER ArchitectureIntroduction to VIPER Architecture
Introduction to VIPER Architecture
Hendy Christianto
 
Rambler.iOS #5: VIPER a la Rambler
Rambler.iOS #5: VIPER a la RamblerRambler.iOS #5: VIPER a la Rambler
Rambler.iOS #5: VIPER a la Rambler
RAMBLER&Co
 
[SIP 2015] iOS Proposal: VIPER
[SIP 2015] iOS Proposal: VIPER[SIP 2015] iOS Proposal: VIPER
[SIP 2015] iOS Proposal: VIPER
Silicon Straits
 
Viper - чистая архитектура iOS-приложения (И. Чирков)
Viper - чистая архитектура iOS-приложения (И. Чирков)Viper - чистая архитектура iOS-приложения (И. Чирков)
Viper - чистая архитектура iOS-приложения (И. Чирков)
65apps
 
ReactiveCocoa: делаем отзывчивое приложение (П. Руденко)
ReactiveCocoa: делаем отзывчивое приложение (П. Руденко)ReactiveCocoa: делаем отзывчивое приложение (П. Руденко)
ReactiveCocoa: делаем отзывчивое приложение (П. Руденко)
65apps
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshop
Jorge Ortiz
 
iOSアプリケーションアーキテクチャ選定の鍵を探す
iOSアプリケーションアーキテクチャ選定の鍵を探すiOSアプリケーションアーキテクチャ選定の鍵を探す
iOSアプリケーションアーキテクチャ選定の鍵を探す
Kenji Tanaka
 
Is Activity God? ~ The MVP Architecture ~
Is Activity God? ~ The MVP Architecture ~Is Activity God? ~ The MVP Architecture ~
Is Activity God? ~ The MVP Architecture ~
Ken William
 
iOS Architecture
iOS ArchitectureiOS Architecture
iOS Architecture
Jacky Lian
 
Viper architecture
Viper architectureViper architecture
Viper architecture
Katerina Korovkina
 
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
e-Legion
 
Rambler.iOS #5: Генерамба и прочие аспекты кодогенерации в VIPER
Rambler.iOS #5: Генерамба и прочие аспекты кодогенерации в VIPERRambler.iOS #5: Генерамба и прочие аспекты кодогенерации в VIPER
Rambler.iOS #5: Генерамба и прочие аспекты кодогенерации в VIPER
RAMBLER&Co
 
An (highly elementary) introduction to VIPER
An (highly elementary) introduction to VIPERAn (highly elementary) introduction to VIPER
An (highly elementary) introduction to VIPER
denicija
 
iOS Viper architecture for CocoaHeadsBY (RU)
iOS Viper architecture for CocoaHeadsBY (RU)iOS Viper architecture for CocoaHeadsBY (RU)
iOS Viper architecture for CocoaHeadsBY (RU)
Vladimir Hudnitsky
 
Rambler.iOS #5: Переходы и передача данных между VIPER модулями
Rambler.iOS #5: Переходы и передача данных между VIPER модулямиRambler.iOS #5: Переходы и передача данных между VIPER модулями
Rambler.iOS #5: Переходы и передача данных между VIPER модулями
RAMBLER&Co
 
Dependence day insurgence
Dependence day insurgenceDependence day insurgence
Dependence day insurgence
Jorge Ortiz
 
Why the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID ArchitectureWhy the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
 
"Clean" Architecture
"Clean" Architecture"Clean" Architecture
"Clean" Architecture
Manfred Touron
 
Rambler.iOS #5: VIPER и Swift
Rambler.iOS #5: VIPER и SwiftRambler.iOS #5: VIPER и Swift
Rambler.iOS #5: VIPER и Swift
RAMBLER&Co
 
Introduction to VIPER Architecture
Introduction to VIPER ArchitectureIntroduction to VIPER Architecture
Introduction to VIPER Architecture
Hendy Christianto
 
Rambler.iOS #5: VIPER a la Rambler
Rambler.iOS #5: VIPER a la RamblerRambler.iOS #5: VIPER a la Rambler
Rambler.iOS #5: VIPER a la Rambler
RAMBLER&Co
 
[SIP 2015] iOS Proposal: VIPER
[SIP 2015] iOS Proposal: VIPER[SIP 2015] iOS Proposal: VIPER
[SIP 2015] iOS Proposal: VIPER
Silicon Straits
 
Viper - чистая архитектура iOS-приложения (И. Чирков)
Viper - чистая архитектура iOS-приложения (И. Чирков)Viper - чистая архитектура iOS-приложения (И. Чирков)
Viper - чистая архитектура iOS-приложения (И. Чирков)
65apps
 
ReactiveCocoa: делаем отзывчивое приложение (П. Руденко)
ReactiveCocoa: делаем отзывчивое приложение (П. Руденко)ReactiveCocoa: делаем отзывчивое приложение (П. Руденко)
ReactiveCocoa: делаем отзывчивое приложение (П. Руденко)
65apps
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshop
Jorge Ortiz
 
iOSアプリケーションアーキテクチャ選定の鍵を探す
iOSアプリケーションアーキテクチャ選定の鍵を探すiOSアプリケーションアーキテクチャ選定の鍵を探す
iOSアプリケーションアーキテクチャ選定の鍵を探す
Kenji Tanaka
 
Is Activity God? ~ The MVP Architecture ~
Is Activity God? ~ The MVP Architecture ~Is Activity God? ~ The MVP Architecture ~
Is Activity God? ~ The MVP Architecture ~
Ken William
 
iOS Architecture
iOS ArchitectureiOS Architecture
iOS Architecture
Jacky Lian
 
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
e-Legion
 
Rambler.iOS #5: Генерамба и прочие аспекты кодогенерации в VIPER
Rambler.iOS #5: Генерамба и прочие аспекты кодогенерации в VIPERRambler.iOS #5: Генерамба и прочие аспекты кодогенерации в VIPER
Rambler.iOS #5: Генерамба и прочие аспекты кодогенерации в VIPER
RAMBLER&Co
 
An (highly elementary) introduction to VIPER
An (highly elementary) introduction to VIPERAn (highly elementary) introduction to VIPER
An (highly elementary) introduction to VIPER
denicija
 
iOS Viper architecture for CocoaHeadsBY (RU)
iOS Viper architecture for CocoaHeadsBY (RU)iOS Viper architecture for CocoaHeadsBY (RU)
iOS Viper architecture for CocoaHeadsBY (RU)
Vladimir Hudnitsky
 
Rambler.iOS #5: Переходы и передача данных между VIPER модулями
Rambler.iOS #5: Переходы и передача данных между VIPER модулямиRambler.iOS #5: Переходы и передача данных между VIPER модулями
Rambler.iOS #5: Переходы и передача данных между VIPER модулями
RAMBLER&Co
 
Dependence day insurgence
Dependence day insurgenceDependence day insurgence
Dependence day insurgence
Jorge Ortiz
 
Why the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID ArchitectureWhy the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
 
Ad

Similar to From mvc to viper (20)

Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
Surbhi Panhalkar
 
iOS_Presentation
iOS_PresentationiOS_Presentation
iOS_Presentation
Emannuel Carvalho
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
Giuliano Iacobelli
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in Arabic
Haitham Shaddad
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101
Rich Helton
 
Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
sreedath c g
 
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
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
Andoni Arroyo
 
深入淺出 MVC
深入淺出 MVC深入淺出 MVC
深入淺出 MVC
Jace Ju
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
Dhaval Kaneria
 
D2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerD2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRoller
WO Community
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
Stefano Paluello
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
Bhavin Shah
 
2013-01-10 iOS testing
2013-01-10 iOS testing2013-01-10 iOS testing
2013-01-10 iOS testing
CocoaHeads Tricity
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
goodfriday
 
I os 11
I os 11I os 11
I os 11
信嘉 陳
 
iPhone Programming in 30 minutes (?) [FTS]
iPhone Programming in 30 minutes (?) [FTS]iPhone Programming in 30 minutes (?) [FTS]
iPhone Programming in 30 minutes (?) [FTS]
Diego Pizzocaro
 
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
iOS testing
iOS testingiOS testing
iOS testing
Tomasz Janeczko
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
Giuliano Iacobelli
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101
Rich Helton
 
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
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
Andoni Arroyo
 
深入淺出 MVC
深入淺出 MVC深入淺出 MVC
深入淺出 MVC
Jace Ju
 
D2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerD2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRoller
WO Community
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
Bhavin Shah
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
goodfriday
 
iPhone Programming in 30 minutes (?) [FTS]
iPhone Programming in 30 minutes (?) [FTS]iPhone Programming in 30 minutes (?) [FTS]
iPhone Programming in 30 minutes (?) [FTS]
Diego Pizzocaro
 
Ad

Recently uploaded (20)

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
 
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
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
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
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
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.
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
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
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
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
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
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
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
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
 
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
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
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
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
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.
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
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
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
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
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
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
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 

From mvc to viper

  • 1. from MVC to VIPER Krzysztof Profic @kprofic
  • 3. Pragmatic approach what hurts my eyes?
  • 4. Pragmatic approach what hurts my eyes? UIViewController
  • 6. 4 Steps • MVC on diet • MVVM • Intentions • VIPER
  • 7. 4 Steps • MVC on diet • MVVM • Intentions • VIPER
  • 8. MVC on diet Massive View Controller Light View Controller
  • 9. Reducing Massive ViewController • extract datasource • move domain logic into the model • move view code into the view layer objc.io #1
  • 10. Reducing Massive ViewController • extract datasource • move domain logic into the model • move view code into the view layer objc.io #1
  • 11. Reducing Massive ViewController • extract datasource • move domain logic into the model • move view code into the view layer objc.io #1
  • 12. Reducing Massive ViewController • Separation of concerns • Single responsibility principle objc.io #1
  • 13. Reanimate your MVC reduce MVC principles violation put ViewController on a diet
  • 14. What is the Rule?
  • 15. “Keep the code where it belongs”
  • 16. Layer
  • 19. Controllers Use Cases Entities Presenters Gateways UI DB External Interfaces Devices The Clean Architecture Enterprise Business Rules Application Business Rules Interface Adapters Frameworks & Drivers Web Controller Use Case Interactor Presenter Use Case Output Port Use Case Input Port Flow of control <I> <I> http://blog.8thlight.com
  • 20. separation of concerns = dividing software into … Layers
  • 21. “Keep the code on the right layer”
  • 23. Controllers Use Cases Entities Presenters Gateways UI DB External Interfaces Devices The Clean Architecture Enterprise Business Rules Application Business Rules Interface Adapters Frameworks & Drivers Web Controller Use Case Interactor Presenter Use Case Output Port Use Case Input Port Flow of control <I> <I> http://blog.8thlight.com
  • 26. MVVM
  • 27. 4 Steps • MVC on diet • MVVM • Intentions • VIPER
  • 29. - (void)viewDidLoad { [super viewDidLoad]; if (self.model.salutation.length > 0) { self.nameLabel.text = [NSString stringWithFormat:@"%@ %@ %@“, self.model.salutation, self.model.firstName, self.model.lastName]; } else { self.nameLabel.text = [NSString stringWithFormat:@"%@ %@“, self.model.firstName, self.model.lastName]; } NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"EEEE MMMM d, yyyy"]; self.birthdateLabel.text = [dateFormatter stringFromDate:model.birthdate]; } PersonViewController.m
  • 30. @implementation PersonViewModel - (instancetype)initWithPerson:(Person *)person { self = [super init]; if (!self) return nil; _person = person; if (person.salutation.length > 0) { _nameText = [NSString stringWithFormat:@"%@ %@ %@“, self.person.salutation, self.person.firstName, self.person.lastName]; } else { _nameText = [NSString stringWithFormat:@"%@ %@", self.person.firstName, self.person.lastName]; } NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"EEEE MMMM d, yyyy"]; _birthdateText = [dateFormatter stringFromDate:person.birthdate]; return self; } @end PersonViewModel.m
  • 31. - (void)viewDidLoad { [super viewDidLoad]; self.nameLabel.text = self.viewModel.nameText; self.birthdateLabel.text = self.viewModel.birthdateText; } PersonViewController.m
  • 32. 4 Steps • MVC on diet • MVVM • Intentions • VIPER
  • 33. Motivation • ViewController implements only viewWill* viewDid*
  • 34. • encapsulate small pieces of business logic • use case approach (form validation, login user) • hookable via & • reusable Intentions Architecture is about Intent “Uncle Bob” IBOutlet IBAction
  • 36. @interface ViewController () @property (strong) IBOutlet ModelContainer* modelContainer; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; PersonViewModel * pvm = [[PersonViewModel alloc] initWithModel:self.person]; self.modelContainer.viewModel = pvm; } @end ViewController.m
  • 38. @interface ObserveIntention () @property (strong, nonatomic) IBOutlet id sourceObject; @property (strong, nonatomic) IBOutlet id target; @property (copy, nonatomic) IBOutlet NSString *sourceKeyPath; @property (copy, nonatomic) IBOutlet NSString *targetKeyPath; @end
  • 39. @implementation ObserveIntention - (void)awakeFromNib { [super awakeFromNib]; [self updateValue]; [self.sourceObject addObserver:self forKeyPath:self.sourceKeyPath options:0 context:nil]; } - (void)updateValue { id value = [self.sourceObject valueForKeyPath: self.sourceKeyPath]; if (self.targetKeyPath) { [self.target setValue:value forKeyPath:self.targetKeyPath]; } } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)obj change:(NSDictionary *)change context:(void *)context { if ([keyPath isEqualToString:self.sourceKeyPath]) { [self updateValue]; } } @end
  • 42. Login
  • 43. User Story #90.10 - Login • A. When I as a user open the app the first time I enter the “main login” page, where I need to login with my username (email address) and password. • B. When I tap the “login button” while online and no errors occur I’m moved to initial page with users profile.
  • 44. User Story #90.10 - Login • A. When I as a user open the app the first time I enter the “main login” page, where I need to login with my username (email address) and password. • B. When I tap the “login button” while online and no errors occur I’m moved to initial page with users profile.
  • 46. @interface LoginIntention() @property (strong) IBOutlet UITextField * usernameTextField; @property (strong) IBOutlet UITextField * passwordTextField; @property (strong, nonatomic) IBOutlet UILabel * statusLabel; @end @implementation LoginIntention - (IBAction)login:(id)sender { self.statusLabel.text = @"connecting..."; [self sendActionsForControlEvents:UIControlEventValueChanged]; self.statusLabel.text = [NSString stringWithFormat:@"Authenticating %@“, self.usernameTextField.text]; [self sendActionsForControlEvents:UIControlEventValueChanged]; self.statusLabel.text = @"done"; [self sendActionsForControlEvents:UIControlEventValueChanged]; } @end LoginIntention.m
  • 47. @implementation LoginViewController - (IBAction)loginIntentionStateChanged:(LoginIntention *)sender { if ([sender.statusLabel.text isEqualToString:@"done"]){ [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; } } @end LoginViewController.m
  • 48. 4 Steps • MVC on diet • MVVM • Intentions • VIPER
  • 49. If you want more, checkout VIPER • View • Interactor • Presenter • Entity • Routing
  • 50. Summary: MVC on diet MVVM Intentions / Behaviours VIPER
  • 51. Thank you! Krzysztof Profic @kprofic
  • 52. • http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean- architecture.html • http://www.scottlogic.com/blog/2014/05/11/ reactivecocoa-tableview-binding.html • http://chris.eidhof.nl/posts/intentions.html • http://www.objc.io/issue-13/behaviors.html • http://www.objc.io/issue-13/viper.html