SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
Vs.
by Brandon D'Imperio
About the presenter
https://coderbits.com/Maslow/
http://www.slideshare.net/MaslowB/
https://nuget.org/profiles/MaslowB/
Knockout
● Inspired by what was already there in the
XAML world
● Declarative Bindings
○ <span data-bind="text:firstname"></span>
● Automatic UI Refresh
○ self.firstname("george"); //automatically changes
the span text
● Dependency Tracking
○ self.name=ko.computed(function(){
■ return self.firstname()+self.lastname();
○ });
Knockout 2
● Templating
○ <ul data-bind="foreach:person">
■ <li data-bind="text:firstname">
○ </ul>
● Initialization
○ var komodel=new PeopleModel();
○ ko.applyBindings(komodel);
Knockout Model
● MVVM
○ 2 way communication with the view
○ The ViewModel represents the view. This means
that fields in a ViewModel usually match up more
closely with the view than with the model.
○ View Communication: There is no IView reference
in the ViewModel. Instead, the view binds directly to
the ViewModel. Because of the binding, changes in
the view are automatically reflected in the
ViewModel and changes in the ViewModel are
automatically reflected in the view.
○ There is a single ViewModel for each view
Knockout Html
Knockout Code
Knockout issues
● self.name= oops
○ self.name('is the setter');
● binding magic variables
○ $data,$parent,$root
● everything is done in one attribute
○ data-bind="text:name,attr:{title:name,'data-id':
personId},click:nameclick"
○ there are addons to help with this
● Code at http://embed.plnkr.co/Gs4U8m/preview
Angular
● Declarative bindings
○ <span>{{newPerson.firstname}}</span>
● Automatic UI Refresh
○ $scope.firstname='george';
○ KO dependency tracking is a clever feature fo
problem which angular does not have.
● MVC
○ Angular likes to say MV*
Angular 2
● Dependency Tracking
○ $scope.fullname=function(){
■ return $scope.firstname+' '+$scope.lastname;
○ };
● Templating
○ <ul ng-repeat="person in people">
■ <li title="person.fullname()"> {{person.
firstname}} </li>
○ </ul>
● Embeddable
○ no global state, multiple angular apps in one page
with no iframe.
Angular 3
● Injectable
○ no main() method
○ Dependency Injection is core
● Testable
○ encourages behavior-view separation
○ pre-bundled with mocks
● Loads more built-in stuff
○ Pluralization Helper
○ Localization Helper
○ Currency and date formatting
○ Script based templating
Angular Issues
● There's so much going on here
○ Is this enterprise library?
○ or `lightweight` emberJs?
● slightly non-predictable directive naming
○ ng-mousedown
○ ng-class-even
● too many ways to do similar or the same
things
○ ngBind vs. {{text}}
○ ng-bind vs. data-ng-bind vs. class="ng-class:
{expression};"
○ ng-bind-template vs. {{text}} {{moretext}}!
Angular Html
Angular Code
Html Comparison
<body>
<ul data-bind="foreach:people">
<li data-bind="text:firstname,attr:
{title:lastname}"></li>
</ul>
<div data-role="add a new person" data-
bind="with:newPerson">
<input data-bind="value:firstname,
valueUpdate:'afterkeydown'"/>
<span data-bind="text:firstname"></span>
<div data-bind="text:fullname"></div>
<input type="button" data-bind="
click:$root.addPerson" value="add"/>
<!-- sample complex binding -->
<div data-bind="text:fullname,attr:
{title:fullname,'data-id':personId},
click:$root.addPerson"></div>
</div> </body>
<body ng-app ng-controller="PersonCtrl">
<ul>
<li ng-repeat="person in people"
title="{{person.lastname}}">{{person.
firstname}}</li>
</ul>
<div data-role="add a new person">
<input ng-model="newPerson.firstname"/>
<span ng-bind="newPerson.firstname"
></span>
<div>{{newPerson.fullname()}}</div>
<input type="button" value="add" ng-
click="addPerson()"/>
</div>
<!-- sample complex binding -->
<div title="{{newPerson.fullname}}" data-
id="{{newPerson.personId}}" ng-click="
addPerson()">{{newPerson.firstname}}</div>
</body>
Code Comparsion
var PersonModel= function(first,last,id) {
var self=this;
self.personId=ko.observable(id);
self.firstname=ko.observable(first);
self.lastname=ko.observable(last);
self.fullname=ko.computed(function(){
return self.firstname()+' '+self.
lastname();
});};
var PeopleModel= function(){
var self=this;
self.newPerson=ko.observable(new
PersonModel('bob','knoblin',1));
self.people=ko.observableArray();
self.addPerson=function(){
self.people.push(self.newPerson());
self.newPerson(new PersonModel
('jane','dough',self.people().length+1));
};
}; var komodel=new PeopleModel(); ko.
applyBindings(komodel);
var angularmodel;
var PersonCtrl= function($scope) {
var PersonModel=function(first,last,id){
var self=this;
self.firstname=first;
self.lastname=last;
self.personId=id || 0;
self.fullname=function(){
return self.firstname+' '+self.
lastname;
}; };
$scope.people=[];
$scope.newPerson=new PersonModel
('bob','knoblin',1);
$scope.addPerson=function(){
$scope.people.push($scope.newPerson);
$scope.newPerson=new PersonModel
('jane','dough',$scope.people.length+1);
};
angularmodel=$scope; };
Similarities
● Fast friendly data-binding
● attribute-based binding
● both can be fully html5 compliant
● custom directives
● Both are better than using jQuery for most
things
● Both may occasionally benefit from a
sprinkling of jQuery
Differences
● Large adoption on knockout
● Angular is backed by google
● MVVM vs. MVC
● Push Model vs. dirty checking
● Angular has a dedicated debugging tool -
Batarang
Knockout vs. Angular
● Far more
lightweight
● Easier to learn
● Focuses on one
area
● Much better
documentation
● Should be faster
● More backwards
(+IE) compat
● Concerns are better
separated
○ attributes and
controller/views
● Has a bigger
toolbox
● Does binding and
mvc
● Better initialization
story
Popularity
Knockout - More question tags on
Stackoverflow in Feb, as of today: 5904 vs 6554
Angular - more stars on github
10k vs. 3.7k and google searches
References
● http://joel.inpointform.net/software-development/mvvm-
vs-mvp-vs-mvc-the-differences-explained/
● http://www.slideshare.net/basarat1/mvvm-knockout-vs-
angular
● http://stackoverflow.
com/questions/9682092/databinding-in-angularjs
● http://odetocode.
com/blogs/scott/archive/2013/02/26/why-use-angularjs.
aspx
● http://jsperf.com/angularjs-vs-knockoutjs
● http://codeutopia.net/blog/2013/03/16/knockout-vs-
backbone-vs-angular/

Contenu connexe

Tendances

Knockoutjs Part 4 Bindings Controlling text and appearance
Knockoutjs Part 4  Bindings  Controlling text and appearanceKnockoutjs Part 4  Bindings  Controlling text and appearance
Knockoutjs Part 4 Bindings Controlling text and appearanceBhaumik Patel
 
Mongo db – document oriented database
Mongo db – document oriented databaseMongo db – document oriented database
Mongo db – document oriented databaseWojciech Sznapka
 
Mastering the MongoDB Shell
Mastering the MongoDB ShellMastering the MongoDB Shell
Mastering the MongoDB ShellMongoDB
 
Mongophilly shell-2011-04-26
Mongophilly shell-2011-04-26Mongophilly shell-2011-04-26
Mongophilly shell-2011-04-26kreuter
 
Simple MongoDB design for Rails apps
Simple MongoDB design for Rails appsSimple MongoDB design for Rails apps
Simple MongoDB design for Rails appsSérgio Santos
 
Broken Authentication and Session Management
Broken Authentication and Session ManagementBroken Authentication and Session Management
Broken Authentication and Session ManagementSongchaiDuangpan
 
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQLENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQLHoracio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQLENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQLHoracio Gonzalez
 
Getting Started with JavaScript
Getting Started with JavaScriptGetting Started with JavaScript
Getting Started with JavaScriptKevin Hoyt
 
Mongo db Quick Guide
Mongo db Quick GuideMongo db Quick Guide
Mongo db Quick GuideSourabh Sahu
 
KEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsKEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsJustin Beckwith
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo dbAmit Thakkar
 

Tendances (15)

Knockoutjs Part 4 Bindings Controlling text and appearance
Knockoutjs Part 4  Bindings  Controlling text and appearanceKnockoutjs Part 4  Bindings  Controlling text and appearance
Knockoutjs Part 4 Bindings Controlling text and appearance
 
MongoDB - Ekino PHP
MongoDB - Ekino PHPMongoDB - Ekino PHP
MongoDB - Ekino PHP
 
Mongo db – document oriented database
Mongo db – document oriented databaseMongo db – document oriented database
Mongo db – document oriented database
 
Mastering the MongoDB Shell
Mastering the MongoDB ShellMastering the MongoDB Shell
Mastering the MongoDB Shell
 
Mongophilly shell-2011-04-26
Mongophilly shell-2011-04-26Mongophilly shell-2011-04-26
Mongophilly shell-2011-04-26
 
Simple MongoDB design for Rails apps
Simple MongoDB design for Rails appsSimple MongoDB design for Rails apps
Simple MongoDB design for Rails apps
 
Rails + mongo db
Rails + mongo dbRails + mongo db
Rails + mongo db
 
Broken Authentication and Session Management
Broken Authentication and Session ManagementBroken Authentication and Session Management
Broken Authentication and Session Management
 
фабрика Blockly
фабрика Blocklyфабрика Blockly
фабрика Blockly
 
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQLENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
 
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQLENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
 
Getting Started with JavaScript
Getting Started with JavaScriptGetting Started with JavaScript
Getting Started with JavaScript
 
Mongo db Quick Guide
Mongo db Quick GuideMongo db Quick Guide
Mongo db Quick Guide
 
KEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsKEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.js
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo db
 

En vedette

Sfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.js
Sfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.jsSfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.js
Sfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.jsVu Hung Nguyen
 
Hands On Intro to Node.js
Hands On Intro to Node.jsHands On Intro to Node.js
Hands On Intro to Node.jsChris Cowan
 
JS Frameworks - Angular Vs Backbone
JS Frameworks - Angular Vs BackboneJS Frameworks - Angular Vs Backbone
JS Frameworks - Angular Vs BackboneGourav Jain, MCTS®
 
wwc start-launched
wwc start-launchedwwc start-launched
wwc start-launchedMat Schaffer
 
PTW Rails Bootcamp
PTW Rails BootcampPTW Rails Bootcamp
PTW Rails BootcampMat Schaffer
 

En vedette (8)

Sfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.js
Sfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.jsSfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.js
Sfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.js
 
Hands On Intro to Node.js
Hands On Intro to Node.jsHands On Intro to Node.js
Hands On Intro to Node.js
 
JS Frameworks - Angular Vs Backbone
JS Frameworks - Angular Vs BackboneJS Frameworks - Angular Vs Backbone
JS Frameworks - Angular Vs Backbone
 
wwc start-launched
wwc start-launchedwwc start-launched
wwc start-launched
 
Node.js
Node.jsNode.js
Node.js
 
PTW Rails Bootcamp
PTW Rails BootcampPTW Rails Bootcamp
PTW Rails Bootcamp
 
Ruby on the Phone
Ruby on the PhoneRuby on the Phone
Ruby on the Phone
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 

Similaire à Knockout vs. angular

The Ring programming language version 1.10 book - Part 53 of 212
The Ring programming language version 1.10 book - Part 53 of 212The Ring programming language version 1.10 book - Part 53 of 212
The Ring programming language version 1.10 book - Part 53 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 53 of 184
The Ring programming language version 1.5.3 book - Part 53 of 184The Ring programming language version 1.5.3 book - Part 53 of 184
The Ring programming language version 1.5.3 book - Part 53 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 43 of 184
The Ring programming language version 1.5.3 book - Part 43 of 184The Ring programming language version 1.5.3 book - Part 43 of 184
The Ring programming language version 1.5.3 book - Part 43 of 184Mahmoud Samir Fayed
 
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksJSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksMario Heiderich
 
GDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSGDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSNicolas Embleton
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack
 
A gentle intro to the Django Framework
A gentle intro to the Django FrameworkA gentle intro to the Django Framework
A gentle intro to the Django FrameworkRicardo Soares
 
Knockout mvvm-m5-slides
Knockout mvvm-m5-slidesKnockout mvvm-m5-slides
Knockout mvvm-m5-slidesMasterCode.vn
 
gDayX - Advanced angularjs
gDayX - Advanced angularjsgDayX - Advanced angularjs
gDayX - Advanced angularjsgdgvietnam
 
Drupalcamp performance
Drupalcamp performanceDrupalcamp performance
Drupalcamp performanceFrontkom
 
moma-django overview --> Django + MongoDB: building a custom ORM layer
moma-django overview --> Django + MongoDB: building a custom ORM layermoma-django overview --> Django + MongoDB: building a custom ORM layer
moma-django overview --> Django + MongoDB: building a custom ORM layerGadi Oren
 
Back to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDBBack to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDBMongoDB
 
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletongDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletonGeorge Nguyen
 
Fly High With Angular - How to build an app using Angular
Fly High With Angular - How to build an app using AngularFly High With Angular - How to build an app using Angular
Fly High With Angular - How to build an app using AngularVacation Labs
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1Paras Mendiratta
 

Similaire à Knockout vs. angular (20)

The Ring programming language version 1.10 book - Part 53 of 212
The Ring programming language version 1.10 book - Part 53 of 212The Ring programming language version 1.10 book - Part 53 of 212
The Ring programming language version 1.10 book - Part 53 of 212
 
The Ring programming language version 1.5.3 book - Part 53 of 184
The Ring programming language version 1.5.3 book - Part 53 of 184The Ring programming language version 1.5.3 book - Part 53 of 184
The Ring programming language version 1.5.3 book - Part 53 of 184
 
The Ring programming language version 1.5.3 book - Part 43 of 184
The Ring programming language version 1.5.3 book - Part 43 of 184The Ring programming language version 1.5.3 book - Part 43 of 184
The Ring programming language version 1.5.3 book - Part 43 of 184
 
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksJSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
 
Nicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JSNicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JS
 
GDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSGDayX - Advanced Angular.JS
GDayX - Advanced Angular.JS
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
 
A gentle intro to the Django Framework
A gentle intro to the Django FrameworkA gentle intro to the Django Framework
A gentle intro to the Django Framework
 
Knockout mvvm-m5-slides
Knockout mvvm-m5-slidesKnockout mvvm-m5-slides
Knockout mvvm-m5-slides
 
gDayX - Advanced angularjs
gDayX - Advanced angularjsgDayX - Advanced angularjs
gDayX - Advanced angularjs
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Drupalcamp performance
Drupalcamp performanceDrupalcamp performance
Drupalcamp performance
 
Dive into AngularJS and directives
Dive into AngularJS and directivesDive into AngularJS and directives
Dive into AngularJS and directives
 
moma-django overview --> Django + MongoDB: building a custom ORM layer
moma-django overview --> Django + MongoDB: building a custom ORM layermoma-django overview --> Django + MongoDB: building a custom ORM layer
moma-django overview --> Django + MongoDB: building a custom ORM layer
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
Back to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDBBack to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDB
 
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletongDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
 
Fly High With Angular - How to build an app using Angular
Fly High With Angular - How to build an app using AngularFly High With Angular - How to build an app using Angular
Fly High With Angular - How to build an app using Angular
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
 

Plus de MaslowB

F# for BLOBA, by brandon d'imperio
F# for BLOBA, by brandon d'imperioF# for BLOBA, by brandon d'imperio
F# for BLOBA, by brandon d'imperioMaslowB
 
Js testing
Js testingJs testing
Js testingMaslowB
 
Type mock isolator
Type mock isolatorType mock isolator
Type mock isolatorMaslowB
 
What’s new mvc 4
What’s new mvc 4What’s new mvc 4
What’s new mvc 4MaslowB
 
A clean repository pattern in ef
A clean repository pattern in efA clean repository pattern in ef
A clean repository pattern in efMaslowB
 
Type mock isolator
Type mock isolatorType mock isolator
Type mock isolatorMaslowB
 
Mvc presentation
Mvc presentationMvc presentation
Mvc presentationMaslowB
 
Metaprogramming by brandon
Metaprogramming by brandonMetaprogramming by brandon
Metaprogramming by brandonMaslowB
 

Plus de MaslowB (9)

F# for BLOBA, by brandon d'imperio
F# for BLOBA, by brandon d'imperioF# for BLOBA, by brandon d'imperio
F# for BLOBA, by brandon d'imperio
 
Js testing
Js testingJs testing
Js testing
 
Type mock isolator
Type mock isolatorType mock isolator
Type mock isolator
 
What’s new mvc 4
What’s new mvc 4What’s new mvc 4
What’s new mvc 4
 
A clean repository pattern in ef
A clean repository pattern in efA clean repository pattern in ef
A clean repository pattern in ef
 
Metrics
MetricsMetrics
Metrics
 
Type mock isolator
Type mock isolatorType mock isolator
Type mock isolator
 
Mvc presentation
Mvc presentationMvc presentation
Mvc presentation
 
Metaprogramming by brandon
Metaprogramming by brandonMetaprogramming by brandon
Metaprogramming by brandon
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

Dernier (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Knockout vs. angular

  • 3. Knockout ● Inspired by what was already there in the XAML world ● Declarative Bindings ○ <span data-bind="text:firstname"></span> ● Automatic UI Refresh ○ self.firstname("george"); //automatically changes the span text ● Dependency Tracking ○ self.name=ko.computed(function(){ ■ return self.firstname()+self.lastname(); ○ });
  • 4. Knockout 2 ● Templating ○ <ul data-bind="foreach:person"> ■ <li data-bind="text:firstname"> ○ </ul> ● Initialization ○ var komodel=new PeopleModel(); ○ ko.applyBindings(komodel);
  • 5. Knockout Model ● MVVM ○ 2 way communication with the view ○ The ViewModel represents the view. This means that fields in a ViewModel usually match up more closely with the view than with the model. ○ View Communication: There is no IView reference in the ViewModel. Instead, the view binds directly to the ViewModel. Because of the binding, changes in the view are automatically reflected in the ViewModel and changes in the ViewModel are automatically reflected in the view. ○ There is a single ViewModel for each view
  • 8. Knockout issues ● self.name= oops ○ self.name('is the setter'); ● binding magic variables ○ $data,$parent,$root ● everything is done in one attribute ○ data-bind="text:name,attr:{title:name,'data-id': personId},click:nameclick" ○ there are addons to help with this ● Code at http://embed.plnkr.co/Gs4U8m/preview
  • 9. Angular ● Declarative bindings ○ <span>{{newPerson.firstname}}</span> ● Automatic UI Refresh ○ $scope.firstname='george'; ○ KO dependency tracking is a clever feature fo problem which angular does not have. ● MVC ○ Angular likes to say MV*
  • 10. Angular 2 ● Dependency Tracking ○ $scope.fullname=function(){ ■ return $scope.firstname+' '+$scope.lastname; ○ }; ● Templating ○ <ul ng-repeat="person in people"> ■ <li title="person.fullname()"> {{person. firstname}} </li> ○ </ul> ● Embeddable ○ no global state, multiple angular apps in one page with no iframe.
  • 11. Angular 3 ● Injectable ○ no main() method ○ Dependency Injection is core ● Testable ○ encourages behavior-view separation ○ pre-bundled with mocks ● Loads more built-in stuff ○ Pluralization Helper ○ Localization Helper ○ Currency and date formatting ○ Script based templating
  • 12. Angular Issues ● There's so much going on here ○ Is this enterprise library? ○ or `lightweight` emberJs? ● slightly non-predictable directive naming ○ ng-mousedown ○ ng-class-even ● too many ways to do similar or the same things ○ ngBind vs. {{text}} ○ ng-bind vs. data-ng-bind vs. class="ng-class: {expression};" ○ ng-bind-template vs. {{text}} {{moretext}}!
  • 15. Html Comparison <body> <ul data-bind="foreach:people"> <li data-bind="text:firstname,attr: {title:lastname}"></li> </ul> <div data-role="add a new person" data- bind="with:newPerson"> <input data-bind="value:firstname, valueUpdate:'afterkeydown'"/> <span data-bind="text:firstname"></span> <div data-bind="text:fullname"></div> <input type="button" data-bind=" click:$root.addPerson" value="add"/> <!-- sample complex binding --> <div data-bind="text:fullname,attr: {title:fullname,'data-id':personId}, click:$root.addPerson"></div> </div> </body> <body ng-app ng-controller="PersonCtrl"> <ul> <li ng-repeat="person in people" title="{{person.lastname}}">{{person. firstname}}</li> </ul> <div data-role="add a new person"> <input ng-model="newPerson.firstname"/> <span ng-bind="newPerson.firstname" ></span> <div>{{newPerson.fullname()}}</div> <input type="button" value="add" ng- click="addPerson()"/> </div> <!-- sample complex binding --> <div title="{{newPerson.fullname}}" data- id="{{newPerson.personId}}" ng-click=" addPerson()">{{newPerson.firstname}}</div> </body>
  • 16. Code Comparsion var PersonModel= function(first,last,id) { var self=this; self.personId=ko.observable(id); self.firstname=ko.observable(first); self.lastname=ko.observable(last); self.fullname=ko.computed(function(){ return self.firstname()+' '+self. lastname(); });}; var PeopleModel= function(){ var self=this; self.newPerson=ko.observable(new PersonModel('bob','knoblin',1)); self.people=ko.observableArray(); self.addPerson=function(){ self.people.push(self.newPerson()); self.newPerson(new PersonModel ('jane','dough',self.people().length+1)); }; }; var komodel=new PeopleModel(); ko. applyBindings(komodel); var angularmodel; var PersonCtrl= function($scope) { var PersonModel=function(first,last,id){ var self=this; self.firstname=first; self.lastname=last; self.personId=id || 0; self.fullname=function(){ return self.firstname+' '+self. lastname; }; }; $scope.people=[]; $scope.newPerson=new PersonModel ('bob','knoblin',1); $scope.addPerson=function(){ $scope.people.push($scope.newPerson); $scope.newPerson=new PersonModel ('jane','dough',$scope.people.length+1); }; angularmodel=$scope; };
  • 17. Similarities ● Fast friendly data-binding ● attribute-based binding ● both can be fully html5 compliant ● custom directives ● Both are better than using jQuery for most things ● Both may occasionally benefit from a sprinkling of jQuery
  • 18. Differences ● Large adoption on knockout ● Angular is backed by google ● MVVM vs. MVC ● Push Model vs. dirty checking ● Angular has a dedicated debugging tool - Batarang
  • 19. Knockout vs. Angular ● Far more lightweight ● Easier to learn ● Focuses on one area ● Much better documentation ● Should be faster ● More backwards (+IE) compat ● Concerns are better separated ○ attributes and controller/views ● Has a bigger toolbox ● Does binding and mvc ● Better initialization story
  • 20. Popularity Knockout - More question tags on Stackoverflow in Feb, as of today: 5904 vs 6554 Angular - more stars on github 10k vs. 3.7k and google searches
  • 21. References ● http://joel.inpointform.net/software-development/mvvm- vs-mvp-vs-mvc-the-differences-explained/ ● http://www.slideshare.net/basarat1/mvvm-knockout-vs- angular ● http://stackoverflow. com/questions/9682092/databinding-in-angularjs ● http://odetocode. com/blogs/scott/archive/2013/02/26/why-use-angularjs. aspx ● http://jsperf.com/angularjs-vs-knockoutjs ● http://codeutopia.net/blog/2013/03/16/knockout-vs- backbone-vs-angular/