Skip to main content

Home/ Coders/ Group items tagged code@tts

Rss Feed Group items tagged

Matteo Spreafico

Classical Inheritance in JavaScript - 0 views

  • function ZParenizor2(value) { var that = new Parenizor(value); that.toString = function () { if (this.getValue()) { return this.uber('toString'); } return "-0-" }; return that; }
    • Matteo Spreafico
       
      This constructors lies, wondeful!
  • Again, we augment Function. We make an instance of the parent class and use it as the new prototype. We also correct the constructor field, and we add the uber method to the prototype as well.
  • This adds a public method to the Function.prototype, so all functions get it by Class Augmentation. It takes a name and a function, and adds them to a function's prototype object.
  • ...3 more annotations...
  • To make the examples above work, I wrote four sugar methods. First, the method method, which adds an instance method to a class. Function.prototype.method = function (name, func) { this.prototype[name] = func; return this; };
  • JavaScript can be used like a classical language, but it also has a level of expressiveness which is quite unique. We have looked at Classical Inheritance, Swiss Inheritance, Parasitic Inheritance, Class Augmentation, and Object Augmentation. This large set of code reuse patterns comes from a language which is considered smaller and simpler than Java.
  • I have been writing JavaScript for 8 years now, and I have never once found need to use an uber function. The super idea is fairly important in the classical pattern, but it appears to be unnecessary in the prototypal and functional patterns. I now see my early attempts to support the classical model in JavaScript as a mistake.
Rick Fan

Extension Versioning, Update and Compatibility - MDC - 0 views

  • The updateURL uses https, or there is no updateURL at all (which defaults to addons.mozilla.org which is https) The updateURL uses http and the updateKey entry is specified which will be used to verify the data in the update manifest.
  • In the update manifest delivered from the updateURL the updateLink must be specified in one of the following ways: The updateLink to the XPI file must use https The updateLink can use http and you must include an updateHash for the XPI file using sha1, sha256, sha384 or sha512 hash algorithms.
1 - 3 of 3
Showing 20 items per page