How we Learned to Stop Worrying and Love JavaScript

1 min read Original article ↗

Transcript

  1. We’ve been busy...

  2. The hardest part...

  3. The hardest part...

  4. The hardest part...

  5. So, talking animals it is... meow!!

  6. Class hierarchies

  7. Class hierarchies WTF? I walk too!

  8. Class hierarchies Duck? WTF? I walk too!

  9. Class hierarchies Duck? WTF? I walk too!

  10. Functional mixins ‣ Mixins as verbs instead of nouns. ‣

    Mixins are functions. We can take advantage of closure scope, arguments and context. ‣ A mixin can be applied to any object type: prototype, instance, whatever. ‣ Advice allows functional mixins to augment existing functions, not clobber them. ‣ Works with the language, simple to understand, no surprises. Debuggable.

  11. Putting it to work...

  12. function Storage() { this.initialize.call(this, arguments); } function baseStorage() { this.initialize

    = function(namespace) { this.namespace = namespace } this.encode = function(item) { return JSON.stringify(item) } this.decode = function(item) { return JSON.parse(item) } if (window.localStorage) { localStorageEngine.call(this); return; } if (document.documentElement.addBehavior) { userDataEngine.call(this); return; } memoryStorageEngine.call(this); } withAdvice.call(Storage.prototype); baseStorage.call(Storage.prototype);

  13. Questions?