Transcript
-
We’ve been busy...
-
The hardest part...
-
The hardest part...
-
The hardest part...
-
So, talking animals it is... meow!!
-
Class hierarchies
-
Class hierarchies WTF? I walk too!
-
Class hierarchies Duck? WTF? I walk too!
-
Class hierarchies Duck? WTF? I walk too!
-
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.
-
Putting it to work...
-
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);
-
Questions?