Mocking Fluent objects in Javascript

Fluent interfaces are an elegant way of expressing functionality in Javascript. Unfortunately, when it comes to stubbing and instrumenting these method calls, one may find it next to impossible to do so – resulting in one or more of the following less-than-ideal outcomes:

  1. Using said library sans fluent interface.
  2. Selecting an alternative on the sole basis of having a non-fluent interface.
  3. Not testing that snippet of functionality altogether.

In this post, we shall mock-up a fluent library called SuperAgent for testing.

Continue reading “Mocking Fluent objects in Javascript”

JS frameworks two-way binding comparison

If you’ve been curious about the MV* Javascript frameworks that all the cool kids are fussing over, Marius Gundersen provides a succinct and valuable cross-section comparison between  AngularJSEmber.js and KnockoutJS.

Extracted from his presentation:

  AngularJS Ember.js KnockoutJS
Binding Dirty Checking Explicit Observable Explicit Observable
Rendering Async Async Sync
Computed Properties
Dynamic Dependencies

Some of Marius’ key takeways:

  1. Ember slowest at rendering lists.
  2. Anguler slowest when model is complex.
  3. Knockout slowest when pushing many items.

More importantly, I take this as a reverse pivot table exercise – see what features are being compared to figure out what they’re actually meant to be doing. Far more informative than “A framework for creating ambitious web applications” or “HTML enhanced for web apps!”.

See: Speaker’s original blog post