Hacker News new | ask | show | jobs
by 38leinad 4799 days ago
I never find an answer to my most daunting question: how is the pattern for doing something like a super call in this prototypal model? bar.prototype.methodname? what if the method is only defined in the proto-prototype? I.e. Foo? Do I then have to explictly know this and write bar.prototype.prototype.methodname?

I hope you know what I mean. This concept of super-calls does not transfer well to prototypal inheritance for me. Are there other patterns that should be used instead?

2 comments

In part 2, which should be published later today, I am going to address "polymorphism" directly, and the punchline is that I'm going to argue that JS doesn't have a good "OO" way of doing relative super calls, and thus you should try to avoid polymorphism. The workaround is indeed an implicit mixin, where you do "ParentConstructor.prototype.method.call(this)", but even though that "works", it's brittle to be hard-wiring your "inheritance" chain across all your polymorphic overridden methods.
thanks for the clarification. that helped a lot to get the understanding straight. always thought I am missing something fundamentally. Looking forward to the read.

in the end i also think super-calls are not a very good concept as you normally don't know what the super calls are doing internally, but somehow it seems like the way to go as almost every mainstream language/framework is supporting/doing it... but i guess that's the general bitter taste i get from classical inheritance...

  PrototypeClass.method.call(this)