SlideShare a Scribd company logo
1 of 20
Techniques that Enable change
Propagation in Modern MVVM
Frameworks
Internal Architecture of FORWARD and Angular
Costas Zarifis
Web and Database Lab
Categories
MVC VS MVVM
Client-Side Frameworks
Framework Internals
1. Model : Represents the real state content – Usually in the form of a
JS object
2. View : Is the user interface
1. ViewModel : Represents the state of the visual layer
4. Controller : Usually imperative programming. Specifies the business
logic and the actions. In MVC it also is responsible for
synchronizing the model and the view
Client-Side Frameworks
Client
MVC VS MVVM
Model
Controller
View
Data Updates
Updates
Action
Utilizes
Model
Controller
View
ViewModel
Data
Updates
Propagates
changes
Rendering
Data
Binding
Action
MVC MVVM
Side
effects
Running Example
lat
options
lng
Position
[0] [1] [n]
map
markers
…
lat
center
lat
lng lat lng
lng
zoom
Position Position
lat lng
[0] [1] [n]
Delivery Trucks
…
Driver’s
Name VIN AVG
Speed
Coords
Shift
Time
Delivery
Progress
Model ViewModel
View
Template
API Calls
Change Propagation in MVVM Frameworks
lat
options
lng
Position
[0] [1] [n]
map
markers
…
lat
center
lat
lng lat lng
lng
zoom
Position Position
lat lng
[0] [1] [n]
Delivery Trucks
…
Driver’s
Name VIN AVG
Speed
Coords
Shift
Time
Delivery
Progress
Model ViewModel
View
Template
API Calls
Change Propagation in MVVM Frameworks
lat
options
lng
Position
[0] [1] [n]
map
markers
…
lat
center
lat
lng lat lng
lng
zoom
Position Position
lat lng
[0] [1] [n]
Delivery Trucks
…
Driver’s
Name VIN AVG
Speed
Coords
Shift
Time
Delivery
Progress
Model ViewModel
View
Template
API Calls
Change Propagation in MVVM Frameworks
lat
options
lng
Position
[0] [1] [n]
map
markers
…
lat
center
lat
lng lat lng
lng
zoom
Position Position
lat lng
[0] [1] [n]
Delivery Trucks
…
Driver’s
Name VIN AVG
Speed
Coords
Shift
Time
Delivery
Progress
Model ViewModel
View
Template
API Calls
Change Propagation in MVVM Frameworks
• Application developers need to add to the $Scope
object the variables that will be used in a Template
Change Propagation in Angular
<ui-gmap-google-map center="map.center"
zoom="map.zoom" bounds="map.bounds">
<ui-gmap-marker ng-repeat="truck in delivery_trucks” coords="truck.coords">
</ui-gmap-marker>
</ui-gmap-google-map>
$http.get('http://forward.ucsd.edu/truck_service’)
.then(function(result) {
$scope.delivery_trucks = result.data;
});
Template
Controller
• When a variable is bound to the template
Angular internally instantiates a watcher.
Change Propagation in Angular
$http.get('http://forward.ucsd.edu/truck_service’)
.then(function(result) {
$scope.delivery_trucks = result.data;
});
Controller
<ui-gmap-google-map center="map.center"
zoom="map.zoom" bounds="map.bounds">
<ui-gmap-marker ng-repeat="truck in delivery_trucks” coords="truck.coords">
</ui-gmap-marker>
</ui-gmap-google-map> Template
Watcher
Watcher
Watcher
• Each Watcher Includes:
– A Watch expression: The result of which is being
watched
– A Listener : The callback function that executes when
the watched object mutates
– Object Equality: variable that dictates the type of
comparison that will be performed to the watched
object (deep vs. shallow)
Watch Expression Listener Object Equality
Change Propagation in Angular
Watcher
• Dirty checking is the process that investigates the watched
object for changes. During this process:
– The old state of the watched object is compared to the current one
– The Object Equality is used to identify which kind of comparison
will be performed
– During deep comparison the old state of the watched object is
traversed and compared with the respective part of the current
object, while during a shallow comparison only the object
reference is checked for changes
– If a change is reported the Listener function is triggered to reflect
the changes to the view
– The body of the listener function most of the times contains
imperative code (and multiple if-then-else’s) in order to identify
which API call can efficiently reflect the changes to the view.
Change Propagation in Angular
• When an action is triggered Angular automatically initiates
the digest cycle. During this process:
Change Propagation in Angular
Watcher
Watcher
Watcher
– Angular iterates over all the declared
watchers and performs dirty checking.
– If some watched object is reported “dirty”,
the listener function is called to reflect the
respective changes to the view
– If m is the number of watchers that have
been declared and n is the size of the
watched object (with n being equal to 1 in
the case of a shallow watch) the
complexity of the algorithm that
propagates changes from the Model to the
View is O(nm)
Watcher
• “Changes” are first-class-citizens in FORWARD
– They are encapsulated using Diffs
– A diff has a payload target and an op:
• Insert
• Update
• Delete
– FORWARD utilizes IVM techniques to generate diffs on the server
and propagate them to the client.
Change Propagation in FORWARD
Server Client
Diffs
• The incoming diffs target parts of the Model
Change Propagation in FORWARD
Model ViewModel View
Diffs
Template Renderer
Calls
• The incoming diffs target parts of the Model
• FORWARD Utilizes Template IVM to translate Model Diffs to
ViewModel Diffs
Change Propagation in FORWARD
Model ViewModel View
Diffs
Template Renderer
Calls
• The incoming diffs target parts of the Model
• FORWARD Utilizes Template IVM to translate Model Diffs to
ViewModel Diffs
• Eventually the respective Renderer Calls reflect the changes
to the View
Change Propagation in FORWARD
Model ViewModel View
Diffs
Template Renderer
Calls
• The Template IVM algorithm traverses the template and
looks for bindings that match an incoming diff
• When such a binding is found the Template is used to
generate the respective ViewModel Diff
• A ViewModel diff has all the information required for the
renderer invocation that will change the application View
• Since there number of potential Visualization Libraries (and
renderers) that can be used in an app is unbounded we
enable Unit Wrapping
Change Propagation in FORWARD
• During Unit Wrapping the Unit
Developer uses diff signatures to specify
renderers
• A diff signature contains:
– A path signature
– An Operator (Insert, Update, Delete)
• A Renderer inputs an incoming diff and
“outputs” the incrementally updated
view
• FORWARD enables Simulation to
simplify Unit Wrapping
• Overall complexity O(d) with d being
the number of incoming diffs
Change Propagation in FORWARD
options
longitude
position
[*]
latitude
map
markers
^

More Related Content

Viewers also liked

N pharma Ciclo de vida del Producto.
N pharma Ciclo de vida del Producto.N pharma Ciclo de vida del Producto.
N pharma Ciclo de vida del Producto.Kevin Yépez
 
Presentacion elafis Brasil 2009
Presentacion elafis Brasil 2009Presentacion elafis Brasil 2009
Presentacion elafis Brasil 2009Fredy Neira
 
29th october 2015 the truth about salvation
29th october 2015   the truth about salvation29th october 2015   the truth about salvation
29th october 2015 the truth about salvationThorn Group Pvt Ltd
 
Whitepaper_From Middle Line to Top Line
Whitepaper_From Middle Line to Top LineWhitepaper_From Middle Line to Top Line
Whitepaper_From Middle Line to Top LineArup Das
 
2016-07-23 08-49-04
2016-07-23 08-49-042016-07-23 08-49-04
2016-07-23 08-49-04Kyle LaFex
 
Whitepaper_E_Customer centricity the survival strategy for Japanese lenders
Whitepaper_E_Customer centricity the survival strategy for Japanese lendersWhitepaper_E_Customer centricity the survival strategy for Japanese lenders
Whitepaper_E_Customer centricity the survival strategy for Japanese lendersArup Das
 
28th october 2015 spiritual death
28th october 2015   spiritual death28th october 2015   spiritual death
28th october 2015 spiritual deathThorn Group Pvt Ltd
 
Antropologia: Modulo 2
Antropologia: Modulo 2Antropologia: Modulo 2
Antropologia: Modulo 2maxilprof
 
The fable of the mouse trap
The fable of the mouse trapThe fable of the mouse trap
The fable of the mouse trapFrances Kazan
 
Evaluation of Mechanical properties of Aluminium based MMC
Evaluation of Mechanical properties of Aluminium based MMCEvaluation of Mechanical properties of Aluminium based MMC
Evaluation of Mechanical properties of Aluminium based MMCBishal Bhandari
 
RELACION DE LA INFORMATICA CON EL DERECHO
RELACION DE LA INFORMATICA CON EL DERECHO RELACION DE LA INFORMATICA CON EL DERECHO
RELACION DE LA INFORMATICA CON EL DERECHO ZARATE_VALERIA
 

Viewers also liked (15)

N pharma Ciclo de vida del Producto.
N pharma Ciclo de vida del Producto.N pharma Ciclo de vida del Producto.
N pharma Ciclo de vida del Producto.
 
Presentacion elafis Brasil 2009
Presentacion elafis Brasil 2009Presentacion elafis Brasil 2009
Presentacion elafis Brasil 2009
 
Shay Johnson
Shay JohnsonShay Johnson
Shay Johnson
 
29th october 2015 the truth about salvation
29th october 2015   the truth about salvation29th october 2015   the truth about salvation
29th october 2015 the truth about salvation
 
Whitepaper_From Middle Line to Top Line
Whitepaper_From Middle Line to Top LineWhitepaper_From Middle Line to Top Line
Whitepaper_From Middle Line to Top Line
 
2016-07-23 08-49-04
2016-07-23 08-49-042016-07-23 08-49-04
2016-07-23 08-49-04
 
02 as bruxas
02   as bruxas02   as bruxas
02 as bruxas
 
Apresentação1
Apresentação1Apresentação1
Apresentação1
 
Whitepaper_E_Customer centricity the survival strategy for Japanese lenders
Whitepaper_E_Customer centricity the survival strategy for Japanese lendersWhitepaper_E_Customer centricity the survival strategy for Japanese lenders
Whitepaper_E_Customer centricity the survival strategy for Japanese lenders
 
28th october 2015 spiritual death
28th october 2015   spiritual death28th october 2015   spiritual death
28th october 2015 spiritual death
 
Antropologia: Modulo 2
Antropologia: Modulo 2Antropologia: Modulo 2
Antropologia: Modulo 2
 
The fable of the mouse trap
The fable of the mouse trapThe fable of the mouse trap
The fable of the mouse trap
 
Evaluation of Mechanical properties of Aluminium based MMC
Evaluation of Mechanical properties of Aluminium based MMCEvaluation of Mechanical properties of Aluminium based MMC
Evaluation of Mechanical properties of Aluminium based MMC
 
Los tulipas sensuales
Los tulipas sensualesLos tulipas sensuales
Los tulipas sensuales
 
RELACION DE LA INFORMATICA CON EL DERECHO
RELACION DE LA INFORMATICA CON EL DERECHO RELACION DE LA INFORMATICA CON EL DERECHO
RELACION DE LA INFORMATICA CON EL DERECHO
 

Similar to Angular vs FORWARD

Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerAction-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerPaul Jones
 
End to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJSEnd to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJSGil Fink
 
Mvvm in the real world tccc10
Mvvm in the real world   tccc10Mvvm in the real world   tccc10
Mvvm in the real world tccc10Bryan Anderson
 
.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9aminmesbahi
 
Architectural Design & Patterns
Architectural Design&PatternsArchitectural Design&Patterns
Architectural Design & PatternsInocentshuja Ahmad
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesQamar Abbas
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to AngularjsGaurav Agrawal
 
Predictable reactive state management - ngrx
Predictable reactive state management - ngrxPredictable reactive state management - ngrx
Predictable reactive state management - ngrxIlia Idakiev
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular jsAayush Shrestha
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation Phan Tuan
 
Common iOS Architecture: From MVC to VIPER, with Redux
Common iOS Architecture: From MVC to VIPER, with ReduxCommon iOS Architecture: From MVC to VIPER, with Redux
Common iOS Architecture: From MVC to VIPER, with ReduxNelson Tai
 

Similar to Angular vs FORWARD (20)

Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerAction-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Angularjs
AngularjsAngularjs
Angularjs
 
End to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJSEnd to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJS
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Mvvm in the real world tccc10
Mvvm in the real world   tccc10Mvvm in the real world   tccc10
Mvvm in the real world tccc10
 
.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9
 
Architectural Design & Patterns
Architectural Design&PatternsArchitectural Design&Patterns
Architectural Design & Patterns
 
MVVM and Prism
MVVM and PrismMVVM and Prism
MVVM and Prism
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
Predictable reactive state management - ngrx
Predictable reactive state management - ngrxPredictable reactive state management - ngrx
Predictable reactive state management - ngrx
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
 
Common iOS Architecture: From MVC to VIPER, with Redux
Common iOS Architecture: From MVC to VIPER, with ReduxCommon iOS Architecture: From MVC to VIPER, with Redux
Common iOS Architecture: From MVC to VIPER, with Redux
 
MVP Clean Architecture
MVP Clean  Architecture MVP Clean  Architecture
MVP Clean Architecture
 
Angular js 1.3 basic tutorial
Angular js 1.3 basic tutorialAngular js 1.3 basic tutorial
Angular js 1.3 basic tutorial
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Angular vs FORWARD

  • 1. Techniques that Enable change Propagation in Modern MVVM Frameworks Internal Architecture of FORWARD and Angular Costas Zarifis Web and Database Lab
  • 3. Framework Internals 1. Model : Represents the real state content – Usually in the form of a JS object 2. View : Is the user interface 1. ViewModel : Represents the state of the visual layer 4. Controller : Usually imperative programming. Specifies the business logic and the actions. In MVC it also is responsible for synchronizing the model and the view
  • 4. Client-Side Frameworks Client MVC VS MVVM Model Controller View Data Updates Updates Action Utilizes Model Controller View ViewModel Data Updates Propagates changes Rendering Data Binding Action MVC MVVM Side effects
  • 6. lat options lng Position [0] [1] [n] map markers … lat center lat lng lat lng lng zoom Position Position lat lng [0] [1] [n] Delivery Trucks … Driver’s Name VIN AVG Speed Coords Shift Time Delivery Progress Model ViewModel View Template API Calls Change Propagation in MVVM Frameworks
  • 7. lat options lng Position [0] [1] [n] map markers … lat center lat lng lat lng lng zoom Position Position lat lng [0] [1] [n] Delivery Trucks … Driver’s Name VIN AVG Speed Coords Shift Time Delivery Progress Model ViewModel View Template API Calls Change Propagation in MVVM Frameworks
  • 8. lat options lng Position [0] [1] [n] map markers … lat center lat lng lat lng lng zoom Position Position lat lng [0] [1] [n] Delivery Trucks … Driver’s Name VIN AVG Speed Coords Shift Time Delivery Progress Model ViewModel View Template API Calls Change Propagation in MVVM Frameworks
  • 9. lat options lng Position [0] [1] [n] map markers … lat center lat lng lat lng lng zoom Position Position lat lng [0] [1] [n] Delivery Trucks … Driver’s Name VIN AVG Speed Coords Shift Time Delivery Progress Model ViewModel View Template API Calls Change Propagation in MVVM Frameworks
  • 10. • Application developers need to add to the $Scope object the variables that will be used in a Template Change Propagation in Angular <ui-gmap-google-map center="map.center" zoom="map.zoom" bounds="map.bounds"> <ui-gmap-marker ng-repeat="truck in delivery_trucks” coords="truck.coords"> </ui-gmap-marker> </ui-gmap-google-map> $http.get('http://forward.ucsd.edu/truck_service’) .then(function(result) { $scope.delivery_trucks = result.data; }); Template Controller
  • 11. • When a variable is bound to the template Angular internally instantiates a watcher. Change Propagation in Angular $http.get('http://forward.ucsd.edu/truck_service’) .then(function(result) { $scope.delivery_trucks = result.data; }); Controller <ui-gmap-google-map center="map.center" zoom="map.zoom" bounds="map.bounds"> <ui-gmap-marker ng-repeat="truck in delivery_trucks” coords="truck.coords"> </ui-gmap-marker> </ui-gmap-google-map> Template Watcher Watcher Watcher
  • 12. • Each Watcher Includes: – A Watch expression: The result of which is being watched – A Listener : The callback function that executes when the watched object mutates – Object Equality: variable that dictates the type of comparison that will be performed to the watched object (deep vs. shallow) Watch Expression Listener Object Equality Change Propagation in Angular Watcher
  • 13. • Dirty checking is the process that investigates the watched object for changes. During this process: – The old state of the watched object is compared to the current one – The Object Equality is used to identify which kind of comparison will be performed – During deep comparison the old state of the watched object is traversed and compared with the respective part of the current object, while during a shallow comparison only the object reference is checked for changes – If a change is reported the Listener function is triggered to reflect the changes to the view – The body of the listener function most of the times contains imperative code (and multiple if-then-else’s) in order to identify which API call can efficiently reflect the changes to the view. Change Propagation in Angular
  • 14. • When an action is triggered Angular automatically initiates the digest cycle. During this process: Change Propagation in Angular Watcher Watcher Watcher – Angular iterates over all the declared watchers and performs dirty checking. – If some watched object is reported “dirty”, the listener function is called to reflect the respective changes to the view – If m is the number of watchers that have been declared and n is the size of the watched object (with n being equal to 1 in the case of a shallow watch) the complexity of the algorithm that propagates changes from the Model to the View is O(nm) Watcher
  • 15. • “Changes” are first-class-citizens in FORWARD – They are encapsulated using Diffs – A diff has a payload target and an op: • Insert • Update • Delete – FORWARD utilizes IVM techniques to generate diffs on the server and propagate them to the client. Change Propagation in FORWARD Server Client Diffs
  • 16. • The incoming diffs target parts of the Model Change Propagation in FORWARD Model ViewModel View Diffs Template Renderer Calls
  • 17. • The incoming diffs target parts of the Model • FORWARD Utilizes Template IVM to translate Model Diffs to ViewModel Diffs Change Propagation in FORWARD Model ViewModel View Diffs Template Renderer Calls
  • 18. • The incoming diffs target parts of the Model • FORWARD Utilizes Template IVM to translate Model Diffs to ViewModel Diffs • Eventually the respective Renderer Calls reflect the changes to the View Change Propagation in FORWARD Model ViewModel View Diffs Template Renderer Calls
  • 19. • The Template IVM algorithm traverses the template and looks for bindings that match an incoming diff • When such a binding is found the Template is used to generate the respective ViewModel Diff • A ViewModel diff has all the information required for the renderer invocation that will change the application View • Since there number of potential Visualization Libraries (and renderers) that can be used in an app is unbounded we enable Unit Wrapping Change Propagation in FORWARD
  • 20. • During Unit Wrapping the Unit Developer uses diff signatures to specify renderers • A diff signature contains: – A path signature – An Operator (Insert, Update, Delete) • A Renderer inputs an incoming diff and “outputs” the incrementally updated view • FORWARD enables Simulation to simplify Unit Wrapping • Overall complexity O(d) with d being the number of incoming diffs Change Propagation in FORWARD options longitude position [*] latitude map markers ^