SlideShare une entreprise Scribd logo
1  sur  35
Télécharger pour lire hors ligne
MV(C,VM) in iOS &
ReactiveCocoa
Neo
Outline
MV* Family
Original
What & why
Components in MVC & MVVM
Architecture
MVC & MVVM in iOS
Something wrong?
ReactiveCocoa
Original
What & why
FRP - Functional Reactive Programming
How to use
Something right?
Conclusion
MV* Family
Original
Trygve Reenskaug(Noway computer scientist)
The original MVC reports [1]

(I made the first implementation 

and wrote the original MVC reports…)
CAD/CAM
MVC be changed a lot, and extended new 

patterns(main principle)
MVC - Model-View-Controller
MVVM - Model-View-ViewModel
MVP - Model-View-Presenter
MTV - Model-Template-View
[1]http://heim.ifi.uio.no/~trygver/2007/MVC_Originals.pdf
What are them?
Design pattern (Architecture pattern)
Diagrams for establish a robust program
architecture
Why need them?
Data, logical, and UI code are like shit in early
code when GUI appearance.
separate concrete of concerns
Handle more and more complex program
Understandable
manageable
maintainable
reusable
etc…
Components in MVC and MVVM
They are same in Model(M) and V(View)
Model (M) - the domain knowledge or data, it can be
simple value, object or class.
View (V) - everything graphical user can see
C in MVC
Controller (C) - A link between model and view, and also
an event handler.
VM in MVVM
ViewModel (VM) - it’s the same as controller, but contain all
jobs which not belong to view/model
What are they different in thinking?
Controller think that they can be three independent
components
ViewModel think that view and controller cannot be
separated clearly
Architecture improvement
Smalltalk’80 MVC
Microsoft MVVM
ref. from:[2]
ref. from:[2]
Architecture improvement
Smalltalk’80 MVC
Microsoft MVVM
ref. from:[2]
ref. from:[2]
ref. from:[3]
Architecture improvement
Smalltalk’80 MVC
Microsoft MVVM
ref. from:[2]
ref. from:[2]
ref. from:[3]
ref. from:[4]
Architecture improvement
Smalltalk’80 MVC
Microsoft MVVM
ref. from:[2]
ref. from:[2]
ref. from:[3]
ref. from:[4]
ref. from:[5]
Architecture improvement
Smalltalk’80 MVC
Microsoft MVVM
ref. from:[2]
ref. from:[2]
It’s divergent
in concepts
ref. from:[3]
ref. from:[4]
ref. from:[5]
Design pattern is still improving and evolving
MVC in iOS
In iOS, model and view always communicate
each other through by controller
Model and view never talk to controller
directly, but controller do.
ref. from:[2]
MVVM in iOS
In iOS, view controller still exist, but same as view’s task
ViewModel handler all controller’s logic block, includes
business logic, presentation logic, network request, etc…
Why is MVC in iOS?
Standard implementation
Objective-C references features of smallTalk
Official tutorial documents or classes all tell us MVC
(These pictures ref. from:[6][7])
Why Cocoa design pattern did not follow
Smarttalk’80 ?
View and model did not loose-couple
It’s not reusable
Ambiguous about what they concern
Simple to see difference in MVCs and MVVM
MVC View model
view No YES
model YES NO
MVC in iOS View model
view No NO
model NO NO
MVVM View model
view No NO
model NO NO
Three tables about components communication
MVC’s example
If i want an very simple App which can
input family name and display what I
input……
A model - Store family data
A view - a App’s GUI for user
A controller - Handle event and user’s
action
View in MVC
View does not provide any method
about data, it just provides accessor’s
method to interaction with controller.
Model in MVC
Model has a class object about data, and some method’s
related data.
Also, it does not care
about View.
Controller in MVC
In the controller, we need to implement:
notification, Delegation or other mechanism to update view or
model.
Event handler(user action or data change)
if interesting, https://github.com/flamelad/MVFamilyPractice
MVVM’s example
Family name App again lol
Difference - MVVMViewModel files
It responses for anything which is not
responded by Model and View
ViewController In MVVM
Where are these functions?
ViewModel In MVVM
Those functions all in ViewModel
But, how communicate with
ViewController?
ViewModel In MVVM
In *.h file, declare all properties which are needed to
show in screen or accepted data input.
ViewController update screen: (KVO, Notification)
Monitor these properties for update properties
ViewController input data: (Accessor method)
Access the property which is designed for receive data in
VewModel
ViewModel
Model ViewController View
delegate
Setter
Accessor Method
Notification

KVO
Notification

KVO
Something wrong?
(Let’s thinking what problem may we meet 

in iOS MVC now…)
Controller god damn fat
Some methods are inexplicit

(ex: network request about data)
KVO and notification mechanism 

lead to difficult understand it
View and controller cannot be 

really separated clearly
Difficult to do unit test
Difficult to understand your 

controllers
ReactiveCocoa is saver..….maybe?
ReactiveCocoa
Original
Github for Mac App’s Developers - Josh & Justin
ReactiveCocoa developed by them when they develop Github for
Mac
What is it
It’s a open source framework which implementation base on
Functional Reactive Programming (FRP)
https://github.com/ReactiveCocoa/ReactiveCocoa
Only supports OS X 10.9+ and iOS 8.0+
new version is concentrated on the Swift
Why is it
The framework with MVVM tried to solve problems what we meet
in MVC
FRP - Functional Reactive
Programming
It’s a programming diagram which combine
reactive programming and functional
programming
Function programming
(Just very simply describe their difference here)
Imperative programming - write and execute steps by step
Ex: for (int i=0;i<arr.count;i++){logical for find MaxNumber};
Functional programming - function, input, output.

Ex: int MaxNumber= MaxNumber(1,10);
Reactive programming
What is it? 

Concept is around data flows and propagation of change
Let’s easy to know it

Ex:
proactive vs. reactive
a = 2;

b = 3;
c = a+b;
a = 3;
Now, c = ?
c = 5 c = 6
After combine functional and reactive programming
It’s like pipe, you do not need to know how the pipe transfer water

It’s like pipe, you put something in, always something out

It’s like pipe, something always are not changed during in the pipe

It’s like pipe, water in the pipe is continuous, data flow too.

It’s like pipe, pipes can be concatenated to process it centrally

It’s like pipe, output can be filter, reduce, and map
What advantages are worth to adapt it?
Code clean - KVO, notification, target-action or observer can be
centralized
Make code more understandable
Decrease problem that value be changed at somewhere
Is it no disadvantage?
No, it is. 

1. it performance is lower than native

2. Debug is difficult

3. return value type always id.
How to start ReactiveCocoa(RAC)?
Getting started

https://github.com/ReactiveCocoa/ReactiveCocoa#getting-started/
Framework overview

https://github.com/ReactiveCocoa/ReactiveCocoa/blob/master/
Documentation/FrameworkOverview.md
There are many component to transfer and process data

Signal, Subjects, Commands, Sequences, Schedulers, mapping, etc……
Familiar it, and then do it
[Simply Demo]
[Demo Page]
Problem thinking again
Controller god damn fat
Some methods are inexplicit (ex: network request
about data)
KVO and notification mechanism lead to difficult
understand it
View and controller cannot be really separated
clearly
Difficult to do unit test
Difficult to understand your controllers
Something right?
According to presentation, we known:

1. MVVM can solve Controller is too fat

2. MVVM can solve concerns ambiguous

3. MVVM can solve redefine View and
ViewController

4. MVVM can be more easier understand
ViewController 

5. ReactiveCocoa can let logical be centralize

6. ReactiveCocoa can help MVVM clear code and
separate
Conclusion
If MVVM is so good, why Apple does not use it?
In fact, although it’s not same all, Apple used some concepts
and logical in OSX App implementation- ref. from:[4]
If MVC is so bad, why Apple use it?
In fact, although MVC has some disadvantage, but it still a
nice design pattern. Of course, the most important is that
ObjC come from smallTalk……
Do we really need reactiveCocoa?
No, not really. It won’t have any help for a engineer grow up.
Yes, it does. it can help us clean code, clear logical, and
centralize code implementation
What time is best to introduce reactiveCocoa?
The most important - it’s just a framework, a tool,
not language.
An Sample Code of MVVM by completion App
https://medium.com/@syshen/reactivecocoa-in-
practice-4f04119efc68
Reference
2)http://ieeexplore.ieee.org/xpl/login.jsp?
tp=&arnumber=6827095&url=http%3A%2F
%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber
%3D6827095
3)http://www.diva-portal.org/smash/get/diva2:738269/
FULLTEXT01.pdfw&bvm=bv.80642063,d.eXY
4)http://www.itu.dk/courses/VOP/E2005/VOP2005E/
8_mvc_krasner_and_pope.pdf
5)https://msdn.microsoft.com/en-us/library/hh848246.aspx
6)http://www.sprynthesis.com/2014/12/06/reactivecocoa-
mvvm-introduction/
7)http://www.objc.io/issue-13/mvvm.html
8)http://www.itiger.me/?p=38 (a lot of sample code)
Q & A
Thanks

Contenu connexe

Tendances

MVVM - Model View ViewModel
MVVM - Model View ViewModelMVVM - Model View ViewModel
MVVM - Model View ViewModelDareen Alhiyari
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009Jonas Follesø
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)Yaroslav Voloshyn
 
MVVM with WPF
MVVM with WPFMVVM with WPF
MVVM with WPFS V
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: AndroidJitendra Kumar
 
Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awtvishal choudhary
 
MVVM Light Toolkit Works Great, Less Complicated
MVVM Light ToolkitWorks Great, Less ComplicatedMVVM Light ToolkitWorks Great, Less Complicated
MVVM Light Toolkit Works Great, Less Complicatedmdc11
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC StructureDipika Wadhvani
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentationG ABHISEK
 
Ui design patterns
Ui design patternsUi design patterns
Ui design patternsJorge Ortiz
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patternsallanh0526
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts frameworks4al_com
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobilenaral
 
Mvc pattern and implementation in java fair
Mvc   pattern   and implementation   in   java fairMvc   pattern   and implementation   in   java fair
Mvc pattern and implementation in java fairTech_MX
 

Tendances (20)

MVVM - Model View ViewModel
MVVM - Model View ViewModelMVVM - Model View ViewModel
MVVM - Model View ViewModel
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
MVVM Lights
MVVM LightsMVVM Lights
MVVM Lights
 
MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)
 
MVVM with WPF
MVVM with WPFMVVM with WPF
MVVM with WPF
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
Struts Ppt 1
Struts Ppt 1Struts Ppt 1
Struts Ppt 1
 
Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awt
 
MVVM Light Toolkit Works Great, Less Complicated
MVVM Light ToolkitWorks Great, Less ComplicatedMVVM Light ToolkitWorks Great, Less Complicated
MVVM Light Toolkit Works Great, Less Complicated
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
MVC
MVCMVC
MVC
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentation
 
Ui design patterns
Ui design patternsUi design patterns
Ui design patterns
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
 
Slide Presentation of MVP Pattern Concept
Slide Presentation of MVP Pattern ConceptSlide Presentation of MVP Pattern Concept
Slide Presentation of MVP Pattern Concept
 
Mvc pattern and implementation in java fair
Mvc   pattern   and implementation   in   java fairMvc   pattern   and implementation   in   java fair
Mvc pattern and implementation in java fair
 

En vedette

MVC na iOS - For-Mobile 2/2013
MVC na iOS - For-Mobile 2/2013MVC na iOS - For-Mobile 2/2013
MVC na iOS - For-Mobile 2/2013Tomáš Jukin
 
Porównanie architektur MVVM i MVC (iOS)
Porównanie architektur MVVM i MVC (iOS)Porównanie architektur MVVM i MVC (iOS)
Porównanie architektur MVVM i MVC (iOS)intive
 
«MVVM в Swift», Александр Зимин, независимый iOS-разработчик
«MVVM в Swift», Александр Зимин, независимый iOS-разработчик«MVVM в Swift», Александр Зимин, независимый iOS-разработчик
«MVVM в Swift», Александр Зимин, независимый iOS-разработчикMail.ru Group
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)Binary Studio
 
«Как общаться и договариваться с заказчиками о проектной работе», Валентин Ша...
«Как общаться и договариваться с заказчиками о проектной работе», Валентин Ша...«Как общаться и договариваться с заказчиками о проектной работе», Валентин Ша...
«Как общаться и договариваться с заказчиками о проектной работе», Валентин Ша...Mail.ru Group
 
ReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparisonReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparison500Tech
 

En vedette (9)

MVC na iOS - For-Mobile 2/2013
MVC na iOS - For-Mobile 2/2013MVC na iOS - For-Mobile 2/2013
MVC na iOS - For-Mobile 2/2013
 
Porównanie architektur MVVM i MVC (iOS)
Porównanie architektur MVVM i MVC (iOS)Porównanie architektur MVVM i MVC (iOS)
Porównanie architektur MVVM i MVC (iOS)
 
MVVM on iOS
MVVM on iOSMVVM on iOS
MVVM on iOS
 
«MVVM в Swift», Александр Зимин, независимый iOS-разработчик
«MVVM в Swift», Александр Зимин, независимый iOS-разработчик«MVVM в Swift», Александр Зимин, независимый iOS-разработчик
«MVVM в Swift», Александр Зимин, независимый iOS-разработчик
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
 
«Как общаться и договариваться с заказчиками о проектной работе», Валентин Ша...
«Как общаться и договариваться с заказчиками о проектной работе», Валентин Ша...«Как общаться и договариваться с заказчиками о проектной работе», Валентин Ша...
«Как общаться и договариваться с заказчиками о проектной работе», Валентин Ша...
 
Angular 2 vs React
Angular 2 vs ReactAngular 2 vs React
Angular 2 vs React
 
React 101
React 101React 101
React 101
 
ReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparisonReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparison
 

Similaire à MV(C, mvvm) in iOS and ReactiveCocoa

ASPNet MVC series for beginers part 1
ASPNet MVC series for beginers part 1ASPNet MVC series for beginers part 1
ASPNet MVC series for beginers part 1Gaurav Arora
 
Asp net mvc series for beginers part 1
Asp net mvc series for beginers part 1Asp net mvc series for beginers part 1
Asp net mvc series for beginers part 1Gaurav Arora
 
Code Camp 06 Model View Presenter Architecture
Code Camp 06   Model View Presenter ArchitectureCode Camp 06   Model View Presenter Architecture
Code Camp 06 Model View Presenter Architecturebitburner93
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET WebskillsCaleb Jenkins
 
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData Edureka!
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP DevelopersEdureka!
 
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
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC PresentationVolkan Uzun
 
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
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernatebwullems
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture Jiby John
 
learn mvc project in 7 day
learn mvc project in 7 daylearn mvc project in 7 day
learn mvc project in 7 dayQuach Long
 
A Brief Note On Asp.Net And Cloud Computing Essay
A Brief Note On Asp.Net And Cloud Computing EssayA Brief Note On Asp.Net And Cloud Computing Essay
A Brief Note On Asp.Net And Cloud Computing EssayLanate Drummond
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
Introdução ao ASP .NET MVC - C. Augusto Proiete
Introdução ao ASP .NET MVC - C. Augusto ProieteIntrodução ao ASP .NET MVC - C. Augusto Proiete
Introdução ao ASP .NET MVC - C. Augusto ProieteComunidade NetPonto
 

Similaire à MV(C, mvvm) in iOS and ReactiveCocoa (20)

ASPNet MVC series for beginers part 1
ASPNet MVC series for beginers part 1ASPNet MVC series for beginers part 1
ASPNet MVC series for beginers part 1
 
Asp net mvc series for beginers part 1
Asp net mvc series for beginers part 1Asp net mvc series for beginers part 1
Asp net mvc series for beginers part 1
 
IntroductionToMVC
IntroductionToMVCIntroductionToMVC
IntroductionToMVC
 
Code Camp 06 Model View Presenter Architecture
Code Camp 06   Model View Presenter ArchitectureCode Camp 06   Model View Presenter Architecture
Code Camp 06 Model View Presenter Architecture
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
 
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
 
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,...
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
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
 
Month 2 report
Month 2 reportMonth 2 report
Month 2 report
 
Building an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernateBuilding an enterprise app in silverlight 4 and NHibernate
Building an enterprise app in silverlight 4 and NHibernate
 
MVC & backbone.js
MVC & backbone.jsMVC & backbone.js
MVC & backbone.js
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
 
learn mvc project in 7 day
learn mvc project in 7 daylearn mvc project in 7 day
learn mvc project in 7 day
 
A Brief Note On Asp.Net And Cloud Computing Essay
A Brief Note On Asp.Net And Cloud Computing EssayA Brief Note On Asp.Net And Cloud Computing Essay
A Brief Note On Asp.Net And Cloud Computing Essay
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
Introdução ao ASP .NET MVC - C. Augusto Proiete
Introdução ao ASP .NET MVC - C. Augusto ProieteIntrodução ao ASP .NET MVC - C. Augusto Proiete
Introdução ao ASP .NET MVC - C. Augusto Proiete
 
MVC in PHP
MVC in PHPMVC in PHP
MVC in PHP
 

Dernier

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
+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
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 

Dernier (20)

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
+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...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 

MV(C, mvvm) in iOS and ReactiveCocoa

  • 1. MV(C,VM) in iOS & ReactiveCocoa Neo
  • 2. Outline MV* Family Original What & why Components in MVC & MVVM Architecture MVC & MVVM in iOS Something wrong? ReactiveCocoa Original What & why FRP - Functional Reactive Programming How to use Something right? Conclusion
  • 3. MV* Family Original Trygve Reenskaug(Noway computer scientist) The original MVC reports [1]
 (I made the first implementation 
 and wrote the original MVC reports…) CAD/CAM MVC be changed a lot, and extended new 
 patterns(main principle) MVC - Model-View-Controller MVVM - Model-View-ViewModel MVP - Model-View-Presenter MTV - Model-Template-View [1]http://heim.ifi.uio.no/~trygver/2007/MVC_Originals.pdf
  • 4. What are them? Design pattern (Architecture pattern) Diagrams for establish a robust program architecture Why need them? Data, logical, and UI code are like shit in early code when GUI appearance. separate concrete of concerns Handle more and more complex program Understandable manageable maintainable reusable etc…
  • 5. Components in MVC and MVVM They are same in Model(M) and V(View) Model (M) - the domain knowledge or data, it can be simple value, object or class. View (V) - everything graphical user can see C in MVC Controller (C) - A link between model and view, and also an event handler. VM in MVVM ViewModel (VM) - it’s the same as controller, but contain all jobs which not belong to view/model What are they different in thinking? Controller think that they can be three independent components ViewModel think that view and controller cannot be separated clearly
  • 6. Architecture improvement Smalltalk’80 MVC Microsoft MVVM ref. from:[2] ref. from:[2]
  • 7. Architecture improvement Smalltalk’80 MVC Microsoft MVVM ref. from:[2] ref. from:[2] ref. from:[3]
  • 8. Architecture improvement Smalltalk’80 MVC Microsoft MVVM ref. from:[2] ref. from:[2] ref. from:[3] ref. from:[4]
  • 9. Architecture improvement Smalltalk’80 MVC Microsoft MVVM ref. from:[2] ref. from:[2] ref. from:[3] ref. from:[4] ref. from:[5]
  • 10. Architecture improvement Smalltalk’80 MVC Microsoft MVVM ref. from:[2] ref. from:[2] It’s divergent in concepts ref. from:[3] ref. from:[4] ref. from:[5] Design pattern is still improving and evolving
  • 11. MVC in iOS In iOS, model and view always communicate each other through by controller Model and view never talk to controller directly, but controller do. ref. from:[2]
  • 12. MVVM in iOS In iOS, view controller still exist, but same as view’s task ViewModel handler all controller’s logic block, includes business logic, presentation logic, network request, etc… Why is MVC in iOS? Standard implementation Objective-C references features of smallTalk Official tutorial documents or classes all tell us MVC (These pictures ref. from:[6][7])
  • 13. Why Cocoa design pattern did not follow Smarttalk’80 ? View and model did not loose-couple It’s not reusable Ambiguous about what they concern Simple to see difference in MVCs and MVVM MVC View model view No YES model YES NO MVC in iOS View model view No NO model NO NO MVVM View model view No NO model NO NO Three tables about components communication
  • 14. MVC’s example If i want an very simple App which can input family name and display what I input…… A model - Store family data A view - a App’s GUI for user A controller - Handle event and user’s action
  • 15. View in MVC View does not provide any method about data, it just provides accessor’s method to interaction with controller.
  • 16. Model in MVC Model has a class object about data, and some method’s related data. Also, it does not care about View.
  • 17. Controller in MVC In the controller, we need to implement: notification, Delegation or other mechanism to update view or model. Event handler(user action or data change) if interesting, https://github.com/flamelad/MVFamilyPractice
  • 18. MVVM’s example Family name App again lol Difference - MVVMViewModel files It responses for anything which is not responded by Model and View
  • 19. ViewController In MVVM Where are these functions?
  • 20. ViewModel In MVVM Those functions all in ViewModel But, how communicate with ViewController?
  • 21. ViewModel In MVVM In *.h file, declare all properties which are needed to show in screen or accepted data input. ViewController update screen: (KVO, Notification) Monitor these properties for update properties ViewController input data: (Accessor method) Access the property which is designed for receive data in VewModel
  • 22. ViewModel Model ViewController View delegate Setter Accessor Method Notification
 KVO Notification
 KVO
  • 23. Something wrong? (Let’s thinking what problem may we meet 
 in iOS MVC now…) Controller god damn fat Some methods are inexplicit
 (ex: network request about data) KVO and notification mechanism 
 lead to difficult understand it View and controller cannot be 
 really separated clearly Difficult to do unit test Difficult to understand your 
 controllers ReactiveCocoa is saver..….maybe?
  • 24. ReactiveCocoa Original Github for Mac App’s Developers - Josh & Justin ReactiveCocoa developed by them when they develop Github for Mac What is it It’s a open source framework which implementation base on Functional Reactive Programming (FRP) https://github.com/ReactiveCocoa/ReactiveCocoa Only supports OS X 10.9+ and iOS 8.0+ new version is concentrated on the Swift Why is it The framework with MVVM tried to solve problems what we meet in MVC
  • 25. FRP - Functional Reactive Programming It’s a programming diagram which combine reactive programming and functional programming Function programming (Just very simply describe their difference here) Imperative programming - write and execute steps by step Ex: for (int i=0;i<arr.count;i++){logical for find MaxNumber}; Functional programming - function, input, output.
 Ex: int MaxNumber= MaxNumber(1,10);
  • 26. Reactive programming What is it? 
 Concept is around data flows and propagation of change Let’s easy to know it
 Ex: proactive vs. reactive a = 2;
 b = 3; c = a+b; a = 3; Now, c = ? c = 5 c = 6
  • 27. After combine functional and reactive programming It’s like pipe, you do not need to know how the pipe transfer water
 It’s like pipe, you put something in, always something out
 It’s like pipe, something always are not changed during in the pipe
 It’s like pipe, water in the pipe is continuous, data flow too.
 It’s like pipe, pipes can be concatenated to process it centrally
 It’s like pipe, output can be filter, reduce, and map What advantages are worth to adapt it? Code clean - KVO, notification, target-action or observer can be centralized Make code more understandable Decrease problem that value be changed at somewhere Is it no disadvantage? No, it is. 
 1. it performance is lower than native
 2. Debug is difficult
 3. return value type always id.
  • 28. How to start ReactiveCocoa(RAC)? Getting started
 https://github.com/ReactiveCocoa/ReactiveCocoa#getting-started/ Framework overview
 https://github.com/ReactiveCocoa/ReactiveCocoa/blob/master/ Documentation/FrameworkOverview.md There are many component to transfer and process data
 Signal, Subjects, Commands, Sequences, Schedulers, mapping, etc…… Familiar it, and then do it [Simply Demo]
  • 29.
  • 31. Problem thinking again Controller god damn fat Some methods are inexplicit (ex: network request about data) KVO and notification mechanism lead to difficult understand it View and controller cannot be really separated clearly Difficult to do unit test Difficult to understand your controllers
  • 32. Something right? According to presentation, we known:
 1. MVVM can solve Controller is too fat
 2. MVVM can solve concerns ambiguous
 3. MVVM can solve redefine View and ViewController
 4. MVVM can be more easier understand ViewController 
 5. ReactiveCocoa can let logical be centralize
 6. ReactiveCocoa can help MVVM clear code and separate
  • 33. Conclusion If MVVM is so good, why Apple does not use it? In fact, although it’s not same all, Apple used some concepts and logical in OSX App implementation- ref. from:[4] If MVC is so bad, why Apple use it? In fact, although MVC has some disadvantage, but it still a nice design pattern. Of course, the most important is that ObjC come from smallTalk…… Do we really need reactiveCocoa? No, not really. It won’t have any help for a engineer grow up. Yes, it does. it can help us clean code, clear logical, and centralize code implementation What time is best to introduce reactiveCocoa? The most important - it’s just a framework, a tool, not language.
  • 34. An Sample Code of MVVM by completion App https://medium.com/@syshen/reactivecocoa-in- practice-4f04119efc68 Reference 2)http://ieeexplore.ieee.org/xpl/login.jsp? tp=&arnumber=6827095&url=http%3A%2F %2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber %3D6827095 3)http://www.diva-portal.org/smash/get/diva2:738269/ FULLTEXT01.pdfw&bvm=bv.80642063,d.eXY 4)http://www.itu.dk/courses/VOP/E2005/VOP2005E/ 8_mvc_krasner_and_pope.pdf 5)https://msdn.microsoft.com/en-us/library/hh848246.aspx 6)http://www.sprynthesis.com/2014/12/06/reactivecocoa- mvvm-introduction/ 7)http://www.objc.io/issue-13/mvvm.html 8)http://www.itiger.me/?p=38 (a lot of sample code)