Drkcore

11 01 2012 javascript closure Tweet

closure libraryはクラシカルな継承を実装してた

closure libraryを試している。

inheritsメソッドってクラス指向だよなぁと思いながらソースコード読んだら(1442行目)、javascpriptパターンでいうところのクラシカルパターンそのものだった。

goog.inherits = function(childCtor, parentCtor) {
  /** @constructor */
  function tempCtor() {};
  tempCtor.prototype = parentCtor.prototype;
  childCtor.superClass_ = parentCtor.prototype;
  childCtor.prototype = new tempCtor();
  childCtor.prototype.constructor = childCtor;
};

テンポラリのオブジェクトをかましていて継承関係はこんな感じになっているんだが、javascriptパターンの6章を読むとクラシカルなパターンの導出過程がわかりやすく書かれているのでオススメです。

classical

ちなみに図はblockdiagで書いてみたのだけど、クラス図っぽくないですね(あとでちゃんと書き方を調べる)。

ProductName JavaScriptパターン ―優れたアプリケーションのための作法
Stoyan Stefanov
オライリージャパン / 2940円 ( 2011-02-16 )


About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021