SlideShare a Scribd company logo
1 of 46
Download to read offline
MVVM pattern in iOS development 
Denis Lebedev, 
iOS Hipster @ Wargaming 
! 
mailto: d_lebedev@wargaming.net 
linkedin: http://linkedin.com/in/dlebedev
Agenda 
Wargaming Service Mobile Apps dept. 
MVC 
MVVM 
Development hints 
Reference
WARGAMING SERVICE MOBILE APPS
SMA department 
We make apps for user engagement 
Quality really matters 
We experiment a lot with new tools & technologies
Apps
MODEL-VIEW-CONTROLLER
MVC Diagram 
View 
Model 
Controller
Classical principles 
Loose coupling 
Model is decoupled; view/controller can listen to it’s changes 
View knows about model, can manipulate controller 
Controller knows everything and “does all the things” ©
View Controller responsibilities 
Owns & manages view’s state 
Acts as the datasource for tableviews 
Maps model’s properties to view values 
…
MASSIVE VIEW CONTROLLER
Real world MVC 
Controllers are ‘almost’ not reusable 
Controllers are large 
View is very tight to it’s controller 
Controllers are hard to unit test
Solving Massive Controller problems 
Separate object acting as tableview dataSource 
ConverterHelper, ‘MyFancyAttributeToStringHelper’, etc..
Testing 
Unit tests of controllers code is pain 
Sort of UI tests (Calabash, KIF) is required
Wrapping up 
MVC is not bad at all.
Wrapping up 
What can we do for better world?
MODEL-VIEW-VIEWMODEL
MVVM Diagram 
View/ 
ViewController ViewModel Model
MVVM Diagram 
Wait what? It’s the same!
Key differences with MVC 
ViewController owns it’s view model 
View model doesn’t know anything about controller
Key differences with MVC 
MVC MVVM 
View/ViewController 
ViewModel 
Model 
ViewController 
View 
Model
MVVM Models 
Can represent single domain entity or collection 
Responsible for fetching/storing data
MVVM Views 
Cocoa note: MVVM view = view + view controller 
view is stateless 
views/view controllers become smaller
MVVM View Models 
encapsulates all view data/properties and binds them to view 
validation logic 
actions
ReactiveCocoa 
Functional reactive paradigm in Cocoa world 
Fancy bindings 
Composes of sync/async events of any kind 
Mature, production-ready framework
ReactiveCocoa 
RAC(self, title) = RACObserve(self, viewModel.nickname);
ReactiveCocoa 
RAC(self, stringType) = [RACObserve(self, model.type) 
map:^id(NSNumber *v) { 
return v.intValue == 0 ? @"zero" : @"non-zero"; 
}];
Benefits 
We don’t need to to test the UI (actually we should) 
We can implement app logic without any UI 
view model is easy testable 
view model are (almost) platform independent
Platform agnostic code 
iPad / iPhone / OS X code sharing 
MVVM + Xamarin = shared Windows / OS X code
How we came to MVVM 
Already familiar with ReactiveCocoa 
Strong need in good internal testing 
Fresh project developed from scratch
DEVELOPMENT HINTS
What actually does view controller? 
Layout 
Animations 
Device rotation 
View transitions 
! 
All sensible state is stored in view model
Instantiation 
Every controller has viewModel property 
Some views may have separate view models 
Inject view model to controller during instantiation 
Inject view model’s important properties during instantiation
ViewModel interface 
RACSignals as model properties where possible 
RACSignal for data requests 
Model property (NSArray, domain object, etc.)
WPAFeaturesViewModel.h 
@interface WPAPlaneFeaturesViewModel : NSObject 
! 
@property (copy, nonatomic) NSArray *planeRows; 
! 
@property (strong, nonatomic, readonly) RACCommand *forwardCommand; 
@property (strong, nonatomic, readonly) RACSignal *forwardHidden; 
! 
@property (strong, nonatomic) RACSignal *nextPlaneTitle; 
! 
- (instancetype)initWithReferencePlane:(WOWPPlane *)plane 
classMates:(NSArray *)planes; 
! 
@end
ViewModel for tableviews 
ViewModel has “rows” property of type NSArray 
Row is some NSObject subclass with data very coupled to cell 
Formatters, etc. are applied to row class, not cell 
Controller binds to “rows” and reloads data after property changes
WPAPlaneRow.h 
@interface WPAPlaneRow : NSObject 
! 
@property (strong, nonatomic) WPAFeature *feature; 
@property (copy, nonatomic) NSString *value; 
@property (copy, nonatomic) NSString *grade; 
@property (copy, nonatomic) NSString *referenceGrade; 
! 
@end
Testing 
ViewModel tests are very obvious and atomic: 
State of model can be determined in any moment 
Property change affects view model internal state 
RACCommand changes view model state 
RACSignal pushes new state to subscribers
Real world testing 
Unit tests for view models 
Integration tests (for controllers) with KIF
IMPERATIVE VS DECLARATIVE
How to be functional and reactive 
Write declarative code instead of imperative 
Describe how properties are related to each other
Functional Reactive view model 
Almost all code is in constructor 
Describes how the view should work in terms of commands and 
properties
Functional Reactive view model 
The login button can be pressed when username and password aren’t 
blank 
! 
The error should be cleared after 5 seconds it was displayed
REFERENCE
Functional Reactive view model 
ReactiveCocoa https://github.com/ReactiveCocoa/ReactiveCocoa 
ReactiveViewModel https://github.com/ReactiveCocoa/ 
ReactiveViewModel 
! 
FRP on iOS https://leanpub.com/iosfrp 
! 
FunctionalReactivePixels https://github.com/AshFurrow/ 
FunctionalReactivePixels 
MVVMExample https://github.com/garnett/MVVMExample
THANK YOU!

More Related Content

What's hot

Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Sumanth Chinthagunta
 
AngularJS with RequireJS
AngularJS with RequireJSAngularJS with RequireJS
AngularJS with RequireJSJohannes Weber
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
Web sockets in Angular
Web sockets in AngularWeb sockets in Angular
Web sockets in AngularYakov Fain
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introductionTania Gonzales
 
Workshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSWorkshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSVisual Engineering
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 
Spring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUGSpring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUGTed Pennings
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architectureMichael He
 
Break the monolith with (B)VIPER Modules
Break the monolith with (B)VIPER ModulesBreak the monolith with (B)VIPER Modules
Break the monolith with (B)VIPER ModulesNicola Zaghini
 

What's hot (20)

MVVM Lights
MVVM LightsMVVM Lights
MVVM Lights
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0
 
AngularJS with RequireJS
AngularJS with RequireJSAngularJS with RequireJS
AngularJS with RequireJS
 
Angularjs
AngularjsAngularjs
Angularjs
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Web sockets in Angular
Web sockets in AngularWeb sockets in Angular
Web sockets in Angular
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
 
Java server faces
Java server facesJava server faces
Java server faces
 
ASp.net Mvc 5
ASp.net Mvc 5ASp.net Mvc 5
ASp.net Mvc 5
 
5 angularjs features
5 angularjs features5 angularjs features
5 angularjs features
 
Workshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSWorkshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJS
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
Jsf presentation
Jsf presentationJsf presentation
Jsf presentation
 
Angular 5
Angular 5Angular 5
Angular 5
 
Spring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUGSpring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUG
 
Vue, vue router, vuex
Vue, vue router, vuexVue, vue router, vuex
Vue, vue router, vuex
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 
Break the monolith with (B)VIPER Modules
Break the monolith with (B)VIPER ModulesBreak the monolith with (B)VIPER Modules
Break the monolith with (B)VIPER Modules
 

Viewers also liked

Александр Зимин — Мобильные интерфейсы будущего
Александр Зимин — Мобильные интерфейсы будущегоАлександр Зимин — Мобильные интерфейсы будущего
Александр Зимин — Мобильные интерфейсы будущегоCocoaHeads
 
UICollectionView — Александр Зимин
UICollectionView — Александр ЗиминUICollectionView — Александр Зимин
UICollectionView — Александр ЗиминCocoaHeads
 
Александр Зимин — Анимация в iOS
Александр Зимин — Анимация в iOSАлександр Зимин — Анимация в iOS
Александр Зимин — Анимация в iOSCocoaHeads
 
Александр Зимин (Alexander Zimin) — UIViewController, откройся!
Александр Зимин (Alexander Zimin) — UIViewController, откройся!Александр Зимин (Alexander Zimin) — UIViewController, откройся!
Александр Зимин (Alexander Zimin) — UIViewController, откройся!CocoaHeads
 
Как и зачем можно создать DSL на Python
Как и зачем можно создать DSL на PythonКак и зачем можно создать DSL на Python
Как и зачем можно создать DSL на PythonPyNSK
 
Интерфейсы в Python
Интерфейсы в PythonИнтерфейсы в Python
Интерфейсы в PythonAndrew Svetlov
 
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 RamblerRAMBLER&Co
 
Чем Python плох для стартапа?
Чем Python плох для стартапа?Чем Python плох для стартапа?
Чем Python плох для стартапа?PyNSK
 
Sexy Architecting. VIPER: MVP on steroids
Sexy Architecting. VIPER: MVP on steroidsSexy Architecting. VIPER: MVP on steroids
Sexy Architecting. VIPER: MVP on steroidsDmytro Zaitsev
 
Rambler.iOS #5: VIPER и Swift
Rambler.iOS #5: VIPER и SwiftRambler.iOS #5: VIPER и Swift
Rambler.iOS #5: VIPER и SwiftRAMBLER&Co
 
Лекция 1. Начало.
Лекция 1. Начало.Лекция 1. Начало.
Лекция 1. Начало.Roman Brovko
 
"Почему язык Lua — это интересно?", Ник Заварицкий, (Mail.ru Group)
"Почему язык Lua — это интересно?", Ник Заварицкий, (Mail.ru Group)"Почему язык Lua — это интересно?", Ник Заварицкий, (Mail.ru Group)
"Почему язык Lua — это интересно?", Ник Заварицкий, (Mail.ru Group)Badoo Development
 
Как создать эффективную презентацию?V 02
Как создать эффективную презентацию?V 02Как создать эффективную презентацию?V 02
Как создать эффективную презентацию?V 02Nadezhda Ivera
 

Viewers also liked (14)

Александр Зимин — Мобильные интерфейсы будущего
Александр Зимин — Мобильные интерфейсы будущегоАлександр Зимин — Мобильные интерфейсы будущего
Александр Зимин — Мобильные интерфейсы будущего
 
UICollectionView — Александр Зимин
UICollectionView — Александр ЗиминUICollectionView — Александр Зимин
UICollectionView — Александр Зимин
 
Александр Зимин — Анимация в iOS
Александр Зимин — Анимация в iOSАлександр Зимин — Анимация в iOS
Александр Зимин — Анимация в iOS
 
Александр Зимин (Alexander Zimin) — UIViewController, откройся!
Александр Зимин (Alexander Zimin) — UIViewController, откройся!Александр Зимин (Alexander Zimin) — UIViewController, откройся!
Александр Зимин (Alexander Zimin) — UIViewController, откройся!
 
Как и зачем можно создать DSL на Python
Как и зачем можно создать DSL на PythonКак и зачем можно создать DSL на Python
Как и зачем можно создать DSL на Python
 
Интерфейсы в Python
Интерфейсы в PythonИнтерфейсы в Python
Интерфейсы в Python
 
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
 
Чем Python плох для стартапа?
Чем Python плох для стартапа?Чем Python плох для стартапа?
Чем Python плох для стартапа?
 
Sexy Architecting. VIPER: MVP on steroids
Sexy Architecting. VIPER: MVP on steroidsSexy Architecting. VIPER: MVP on steroids
Sexy Architecting. VIPER: MVP on steroids
 
VIPER - Design Pattern
VIPER - Design PatternVIPER - Design Pattern
VIPER - Design Pattern
 
Rambler.iOS #5: VIPER и Swift
Rambler.iOS #5: VIPER и SwiftRambler.iOS #5: VIPER и Swift
Rambler.iOS #5: VIPER и Swift
 
Лекция 1. Начало.
Лекция 1. Начало.Лекция 1. Начало.
Лекция 1. Начало.
 
"Почему язык Lua — это интересно?", Ник Заварицкий, (Mail.ru Group)
"Почему язык Lua — это интересно?", Ник Заварицкий, (Mail.ru Group)"Почему язык Lua — это интересно?", Ник Заварицкий, (Mail.ru Group)
"Почему язык Lua — это интересно?", Ник Заварицкий, (Mail.ru Group)
 
Как создать эффективную презентацию?V 02
Как создать эффективную презентацию?V 02Как создать эффективную презентацию?V 02
Как создать эффективную презентацию?V 02
 

Similar to Встреча №9. Будущее паттерна MVVM в iOS приложениях, Денис Лебедев

Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Svetlin Nakov
 
Spring MVC framework features and concepts
Spring MVC framework features and conceptsSpring MVC framework features and concepts
Spring MVC framework features and conceptsAsmaShaikh478737
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentationivpol
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET WebskillsCaleb Jenkins
 
MVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - IndiandotnetMVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - IndiandotnetIndiandotnet
 
Using a model view-view model architecture for iOS apps
Using a model view-view model architecture for iOS appsUsing a model view-view model architecture for iOS apps
Using a model view-view model architecture for iOS appsallanh0526
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
Model-View-Controller: Tips&Tricks
Model-View-Controller: Tips&TricksModel-View-Controller: Tips&Tricks
Model-View-Controller: Tips&TricksCiklum Ukraine
 
Mobile architecture problems and solutions.
Mobile architecture problems and solutions.Mobile architecture problems and solutions.
Mobile architecture problems and solutions.PiXeL16
 
My perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsMy perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsPaul Blundell
 
MVP Mix 2015 Leveraging MVVM on all Platforms
MVP Mix 2015  Leveraging MVVM on all PlatformsMVP Mix 2015  Leveraging MVVM on all Platforms
MVP Mix 2015 Leveraging MVVM on all PlatformsJames Montemagno
 
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
 

Similar to Встреча №9. Будущее паттерна MVVM в iOS приложениях, Денис Лебедев (20)

Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
 
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
 
Valentine with AngularJS
Valentine with AngularJSValentine with AngularJS
Valentine with AngularJS
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
A4 from rad to mvc
A4 from rad to mvcA4 from rad to mvc
A4 from rad to mvc
 
Spring MVC framework features and concepts
Spring MVC framework features and conceptsSpring MVC framework features and concepts
Spring MVC framework features and concepts
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
MVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - IndiandotnetMVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - Indiandotnet
 
Using a model view-view model architecture for iOS apps
Using a model view-view model architecture for iOS appsUsing a model view-view model architecture for iOS apps
Using a model view-view model architecture for iOS apps
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
Model-View-Controller: Tips&Tricks
Model-View-Controller: Tips&TricksModel-View-Controller: Tips&Tricks
Model-View-Controller: Tips&Tricks
 
Swiz DAO
Swiz DAOSwiz DAO
Swiz DAO
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
 
Mobile architecture problems and solutions.
Mobile architecture problems and solutions.Mobile architecture problems and solutions.
Mobile architecture problems and solutions.
 
My perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsMy perspective on MVP and architecture discussions
My perspective on MVP and architecture discussions
 
MVP Mix 2015 Leveraging MVVM on all Platforms
MVP Mix 2015  Leveraging MVVM on all PlatformsMVP Mix 2015  Leveraging MVVM on all Platforms
MVP Mix 2015 Leveraging MVVM on all Platforms
 
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
 

More from CocoaHeads

Дизайнер, разработчик, нет конфликта, нет драмы — Евгения Малкова
Дизайнер, разработчик, нет конфликта, нет драмы — Евгения МалковаДизайнер, разработчик, нет конфликта, нет драмы — Евгения Малкова
Дизайнер, разработчик, нет конфликта, нет драмы — Евгения МалковаCocoaHeads
 
Эффективность на рубеже UITableView — Александр Зимин
Эффективность на рубеже UITableView — Александр ЗиминЭффективность на рубеже UITableView — Александр Зимин
Эффективность на рубеже UITableView — Александр ЗиминCocoaHeads
 
Влад Ковташ — Yap Database
Влад Ковташ — Yap DatabaseВлад Ковташ — Yap Database
Влад Ковташ — Yap DatabaseCocoaHeads
 
Push Notifications
Push NotificationsPush Notifications
Push NotificationsCocoaHeads
 
Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...
Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...
Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...CocoaHeads
 
Встреча №9. AudioBus: Эволюция звука, Данил Пархоменко
Встреча №9. AudioBus: Эволюция звука, Данил ПархоменкоВстреча №9. AudioBus: Эволюция звука, Данил Пархоменко
Встреча №9. AudioBus: Эволюция звука, Данил ПархоменкоCocoaHeads
 
Встреча №8. NSIncrementalStore, или как заставить Core Data варить ваш собств...
Встреча №8. NSIncrementalStore, или как заставить Core Data варить ваш собств...Встреча №8. NSIncrementalStore, или как заставить Core Data варить ваш собств...
Встреча №8. NSIncrementalStore, или как заставить Core Data варить ваш собств...CocoaHeads
 
Встреча №8. RESTful клиент — это просто. Тонкости использования RestKit, Миха...
Встреча №8. RESTful клиент — это просто. Тонкости использования RestKit, Миха...Встреча №8. RESTful клиент — это просто. Тонкости использования RestKit, Миха...
Встреча №8. RESTful клиент — это просто. Тонкости использования RestKit, Миха...CocoaHeads
 
Встреча №8. Использование возможностей iOS 7 SDK, Ксения Покровская
Встреча №8. Использование возможностей iOS 7 SDK, Ксения ПокровскаяВстреча №8. Использование возможностей iOS 7 SDK, Ксения Покровская
Встреча №8. Использование возможностей iOS 7 SDK, Ксения ПокровскаяCocoaHeads
 
Встреча №5. Взаимодействие между дизайнерами и разработчиками, Евгений Беляев
Встреча №5. Взаимодействие между дизайнерами и разработчиками, Евгений БеляевВстреча №5. Взаимодействие между дизайнерами и разработчиками, Евгений Беляев
Встреча №5. Взаимодействие между дизайнерами и разработчиками, Евгений БеляевCocoaHeads
 
Встреча №5. Можно ли сделать дизайн без дизайнера? Александр Киров
Встреча №5. Можно ли сделать дизайн без дизайнера? Александр КировВстреча №5. Можно ли сделать дизайн без дизайнера? Александр Киров
Встреча №5. Можно ли сделать дизайн без дизайнера? Александр КировCocoaHeads
 
Встреча №5. Звук и ресурсы iOS в realtime, Константин Платов
Встреча №5. Звук и ресурсы iOS в realtime, Константин ПлатовВстреча №5. Звук и ресурсы iOS в realtime, Константин Платов
Встреча №5. Звук и ресурсы iOS в realtime, Константин ПлатовCocoaHeads
 

More from CocoaHeads (12)

Дизайнер, разработчик, нет конфликта, нет драмы — Евгения Малкова
Дизайнер, разработчик, нет конфликта, нет драмы — Евгения МалковаДизайнер, разработчик, нет конфликта, нет драмы — Евгения Малкова
Дизайнер, разработчик, нет конфликта, нет драмы — Евгения Малкова
 
Эффективность на рубеже UITableView — Александр Зимин
Эффективность на рубеже UITableView — Александр ЗиминЭффективность на рубеже UITableView — Александр Зимин
Эффективность на рубеже UITableView — Александр Зимин
 
Влад Ковташ — Yap Database
Влад Ковташ — Yap DatabaseВлад Ковташ — Yap Database
Влад Ковташ — Yap Database
 
Push Notifications
Push NotificationsPush Notifications
Push Notifications
 
Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...
Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...
Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...
 
Встреча №9. AudioBus: Эволюция звука, Данил Пархоменко
Встреча №9. AudioBus: Эволюция звука, Данил ПархоменкоВстреча №9. AudioBus: Эволюция звука, Данил Пархоменко
Встреча №9. AudioBus: Эволюция звука, Данил Пархоменко
 
Встреча №8. NSIncrementalStore, или как заставить Core Data варить ваш собств...
Встреча №8. NSIncrementalStore, или как заставить Core Data варить ваш собств...Встреча №8. NSIncrementalStore, или как заставить Core Data варить ваш собств...
Встреча №8. NSIncrementalStore, или как заставить Core Data варить ваш собств...
 
Встреча №8. RESTful клиент — это просто. Тонкости использования RestKit, Миха...
Встреча №8. RESTful клиент — это просто. Тонкости использования RestKit, Миха...Встреча №8. RESTful клиент — это просто. Тонкости использования RestKit, Миха...
Встреча №8. RESTful клиент — это просто. Тонкости использования RestKit, Миха...
 
Встреча №8. Использование возможностей iOS 7 SDK, Ксения Покровская
Встреча №8. Использование возможностей iOS 7 SDK, Ксения ПокровскаяВстреча №8. Использование возможностей iOS 7 SDK, Ксения Покровская
Встреча №8. Использование возможностей iOS 7 SDK, Ксения Покровская
 
Встреча №5. Взаимодействие между дизайнерами и разработчиками, Евгений Беляев
Встреча №5. Взаимодействие между дизайнерами и разработчиками, Евгений БеляевВстреча №5. Взаимодействие между дизайнерами и разработчиками, Евгений Беляев
Встреча №5. Взаимодействие между дизайнерами и разработчиками, Евгений Беляев
 
Встреча №5. Можно ли сделать дизайн без дизайнера? Александр Киров
Встреча №5. Можно ли сделать дизайн без дизайнера? Александр КировВстреча №5. Можно ли сделать дизайн без дизайнера? Александр Киров
Встреча №5. Можно ли сделать дизайн без дизайнера? Александр Киров
 
Встреча №5. Звук и ресурсы iOS в realtime, Константин Платов
Встреча №5. Звук и ресурсы iOS в realtime, Константин ПлатовВстреча №5. Звук и ресурсы iOS в realtime, Константин Платов
Встреча №5. Звук и ресурсы iOS в realtime, Константин Платов
 

Recently uploaded

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 

Встреча №9. Будущее паттерна MVVM в iOS приложениях, Денис Лебедев

  • 1. MVVM pattern in iOS development Denis Lebedev, iOS Hipster @ Wargaming ! mailto: d_lebedev@wargaming.net linkedin: http://linkedin.com/in/dlebedev
  • 2.
  • 3. Agenda Wargaming Service Mobile Apps dept. MVC MVVM Development hints Reference
  • 5. SMA department We make apps for user engagement Quality really matters We experiment a lot with new tools & technologies
  • 8. MVC Diagram View Model Controller
  • 9. Classical principles Loose coupling Model is decoupled; view/controller can listen to it’s changes View knows about model, can manipulate controller Controller knows everything and “does all the things” ©
  • 10. View Controller responsibilities Owns & manages view’s state Acts as the datasource for tableviews Maps model’s properties to view values …
  • 12. Real world MVC Controllers are ‘almost’ not reusable Controllers are large View is very tight to it’s controller Controllers are hard to unit test
  • 13. Solving Massive Controller problems Separate object acting as tableview dataSource ConverterHelper, ‘MyFancyAttributeToStringHelper’, etc..
  • 14. Testing Unit tests of controllers code is pain Sort of UI tests (Calabash, KIF) is required
  • 15. Wrapping up MVC is not bad at all.
  • 16. Wrapping up What can we do for better world?
  • 18. MVVM Diagram View/ ViewController ViewModel Model
  • 19. MVVM Diagram Wait what? It’s the same!
  • 20. Key differences with MVC ViewController owns it’s view model View model doesn’t know anything about controller
  • 21. Key differences with MVC MVC MVVM View/ViewController ViewModel Model ViewController View Model
  • 22. MVVM Models Can represent single domain entity or collection Responsible for fetching/storing data
  • 23. MVVM Views Cocoa note: MVVM view = view + view controller view is stateless views/view controllers become smaller
  • 24. MVVM View Models encapsulates all view data/properties and binds them to view validation logic actions
  • 25. ReactiveCocoa Functional reactive paradigm in Cocoa world Fancy bindings Composes of sync/async events of any kind Mature, production-ready framework
  • 26. ReactiveCocoa RAC(self, title) = RACObserve(self, viewModel.nickname);
  • 27. ReactiveCocoa RAC(self, stringType) = [RACObserve(self, model.type) map:^id(NSNumber *v) { return v.intValue == 0 ? @"zero" : @"non-zero"; }];
  • 28. Benefits We don’t need to to test the UI (actually we should) We can implement app logic without any UI view model is easy testable view model are (almost) platform independent
  • 29. Platform agnostic code iPad / iPhone / OS X code sharing MVVM + Xamarin = shared Windows / OS X code
  • 30. How we came to MVVM Already familiar with ReactiveCocoa Strong need in good internal testing Fresh project developed from scratch
  • 32. What actually does view controller? Layout Animations Device rotation View transitions ! All sensible state is stored in view model
  • 33. Instantiation Every controller has viewModel property Some views may have separate view models Inject view model to controller during instantiation Inject view model’s important properties during instantiation
  • 34. ViewModel interface RACSignals as model properties where possible RACSignal for data requests Model property (NSArray, domain object, etc.)
  • 35. WPAFeaturesViewModel.h @interface WPAPlaneFeaturesViewModel : NSObject ! @property (copy, nonatomic) NSArray *planeRows; ! @property (strong, nonatomic, readonly) RACCommand *forwardCommand; @property (strong, nonatomic, readonly) RACSignal *forwardHidden; ! @property (strong, nonatomic) RACSignal *nextPlaneTitle; ! - (instancetype)initWithReferencePlane:(WOWPPlane *)plane classMates:(NSArray *)planes; ! @end
  • 36. ViewModel for tableviews ViewModel has “rows” property of type NSArray Row is some NSObject subclass with data very coupled to cell Formatters, etc. are applied to row class, not cell Controller binds to “rows” and reloads data after property changes
  • 37. WPAPlaneRow.h @interface WPAPlaneRow : NSObject ! @property (strong, nonatomic) WPAFeature *feature; @property (copy, nonatomic) NSString *value; @property (copy, nonatomic) NSString *grade; @property (copy, nonatomic) NSString *referenceGrade; ! @end
  • 38. Testing ViewModel tests are very obvious and atomic: State of model can be determined in any moment Property change affects view model internal state RACCommand changes view model state RACSignal pushes new state to subscribers
  • 39. Real world testing Unit tests for view models Integration tests (for controllers) with KIF
  • 41. How to be functional and reactive Write declarative code instead of imperative Describe how properties are related to each other
  • 42. Functional Reactive view model Almost all code is in constructor Describes how the view should work in terms of commands and properties
  • 43. Functional Reactive view model The login button can be pressed when username and password aren’t blank ! The error should be cleared after 5 seconds it was displayed
  • 45. Functional Reactive view model ReactiveCocoa https://github.com/ReactiveCocoa/ReactiveCocoa ReactiveViewModel https://github.com/ReactiveCocoa/ ReactiveViewModel ! FRP on iOS https://leanpub.com/iosfrp ! FunctionalReactivePixels https://github.com/AshFurrow/ FunctionalReactivePixels MVVMExample https://github.com/garnett/MVVMExample