>  2007/06/18 (月) 11:06:50        [qwerty]
> > http://developer.mozilla.org/ja/docs/Core_JavaScript_1.5_Guide:Property_Inheritance_Revisited:No_Multiple_Inheritance
> > これに改良を加えたようなもので誤魔化してます(;´Д`)
> > 言語レベルでの継承じゃないので問題(コンストラクタとか)も出てくるのでクラス作成・クラスから継承とか諸々全ては自作クラスファクトリを経由するようにして対処してる
> > お陰で抽象クラスもどきからの継承とinstansofの使用によるメソッドの保証とか出来るので精神的(;´Д`)
> > var IO = Factory.create();
> > IO.prototype = {
> >    initlaize: function() { throw 'can not create'; },
> >    read: finction() {...},
> >    coreIO: ...
> > };
> > var io = new IO; // error
> > var FileIO = Factory.create(IO);
> > FileIO.prototype = {
> >    initlaize: function(string path) {... },
> >    ...
> > };
> > var f = new FileIO('unkomoretawarai.txt'); // OK
> > alert(f instanceof IO) // true
> > 適当な例だけどこんな感じ(;´Д`)
> 書き忘れた(;´Д`)抽象クラス使うとこういうのが簡単に出来るので楽
> var Writer =Factory.create();
> Writer.prototype = {
>    initialize: function(io) {
>       if(!(io instanceof IO)) { throw new IOError; }
>       ...
>    }, ...
> };

なるほど(;´Д`)わかりやすい
ところでprototypeに親を入れないとinstanceofで継承チェーンのチェック出来ないんじゃないのかな?

参考:2007/06/18(月)10時54分52秒