Knockout vs AngularJS

MB
by Martin Briano14 views·Updated Jul 2, 2013
Powered by AI

Need to present on this topic?

Create your own polished presentation in minutes. Just describe what you need.

Free to try, no credit card required

Transcript

Data binding!

Data binding?

Starting Point

The Winners

  • Provides templating
  • Can be replaced
  • Provides two-ways data binding
  • Second in line regarding community support
  • Started 3 years ago
  • Is a data-binding library with templating
  • Provides templating
  • Can be extended
  • Provides two-ways data binding
  • Provides routing module
  • Has plenty of community support
  • Started 4 years ago.
  • Provides testing functions
  • Is a full framework

Data binding!

Templating

  • Initial list of about 10 different tools
  • Knockout
  • AngularJS
  • Ember
  • Dust
  • Handlebars
  • ...
  • We evaluated mainly the following dimensions:
  • Community support
  • Maturity
  • Successful cases
  • Templating
  • Data-binding
  • Dependency injection
  • ...

Templating flavors

A technique to isolate what to show from how to show it

logic-less vs. embedded logic

  • control structures in views vs. all the logic in controllers
  • Still subject to debate

single-page vs. external composition

  • use of partials (reusability)
  • implementing the Decorator pattern to avoid having invalid HTML

Templating

before the solution, what's the problem?

  • Coding DOM manipulation is slow!
  • Dynamically changing HTML is cumbersome with plain old javascript
  • You have to store HTML strings
  • It's hard to maintain
  • It's hard to split work among a team (Designers, developers, etc)

º

Research

By Martin Briano & Rodrigo Uroz

  • Better templating system
  • Uses partials -> easier collaboration
  • Integrated with data-binding
  • Integrated routing support
  • Implements MVC pattern
  • but, it is not easy to share contexts within pages
  • Documentation is not too clear
  • Lots of complains form users about this
  • Not intrusive into JS code. (Model properties)
  • Native templating not too developed
  • We improved it by implementing a custom partials managing tool
  • Data binding must be explicit
  • Redefines JS objects turning variables into functions.
  • Changes the normal way of handling the "observable" variables
  • Doesn't provide a routing module, but integrates OK with other libraries (ie: Sammy)

The Results

Proof of concept

Use Cases:

  • Show a list of students
  • as a list
  • as thumbnails
  • Modify a field within the list
  • Show single student detail page
  • Apply absence to a sub-set of students
  • Communicate with backend using R/W REST-Services

Conclusions

Goals

Why a javascript framework?

  • Client tiers are becoming more and more powerfull
  • More computer power and memory in client software than when the web was created?
  • It helps spread responsibility: the server handles the storing and business rules, the client knows how to show the data and interpretes client input with its own logic
  • It balances load between server and client (servers don't get overloaded with client logic)
  • Both tools are very good.
  • Angular joins different modules in a consistently way.
  • Knockout is easier to customize, but may lead into messy code and conflicts between libraries.
  • It's true that having multiple tools makes it easier to change one small part of the app, but... does it happens frequently? Isn't it better to have a single integrated tool that is more likely to work well isolated?
  • Which one to use will depend on project size and app growth expected.
  • Study trending client-side libraries and frameworks
  • Get close to the development experience using these tools.
  • Understand pros/cons to provide support on the decision on which approach is more convenient:
  • Multiple individual libraries, vs
  • One single framework
  • Share knowledge with the rest of the dev team.

What's next?

Questions?

Thank you!!!

  • Extend use cases to do a deeper analysis on these two tools.
  • Extend research to other good qualified options. i.e: Ember.js
  • Discuss with the team which approach is more convenient according to projects future.

Knockout vs. AngularJS