Prev: How to link CSS(s) already linked to parent frame into child iframe using javascript
Next: Error getElementbyClassName
From: David Mark on 13 Jan 2010 04:37 Jorge wrote: > On Jan 13, 10:23 am, David Mark <dmark.cins...(a)gmail.com> wrote: >> (...) No matter how you call your "super-classes", >> it's not going to be a revelation here. ;) > > That's true, as it's in one of Crockford's videos and in at least one > msg in c.l.js. Then everyone already knows about whatever it is you are having trouble explaining. You can just skip it. Thanks!
From: Jorge on 13 Jan 2010 05:10 On Jan 13, 10:37 am, David Mark <dmark.cins...(a)gmail.com> wrote: > Jorge wrote: > > On Jan 13, 10:23 am, David Mark <dmark.cins...(a)gmail.com> wrote: > >> (...) No matter how you call your "super-classes", > >> it's not going to be a revelation here. ;) > > > That's true, as it's in one of Crockford's videos and in at least one > > msg in c.l.js. > > Then everyone already knows about whatever it is you are having trouble > explaining. You can just skip it. Thanks! But you -the truly master, the teacher of Resigs- don't even realize it yet ? -- Jorge.
From: Jorge on 13 Jan 2010 05:23 On Jan 13, 11:18 am, David Mark <dmark.cins...(a)gmail.com> wrote: > > (..) and I don't want you > spreading such goofy patterns in here. (..) Am I? What pattern, exactly ? :-) -- Jorge.
From: David Mark on 13 Jan 2010 05:34 Jorge wrote: > On Jan 13, 11:18 am, David Mark <dmark.cins...(a)gmail.com> wrote: >> (..) and I don't want you >> spreading such goofy patterns in here. (..) > > Am I? What pattern, exactly ? :-) Why, the uh... Nice try, Jorge. I really wish you'd go away.
From: Thomas 'PointedEars' Lahn on 13 Jan 2010 07:05
Jorge wrote: > Thomas 'PointedEars' Lahn wrote: >> Jorge wrote: >> > Thomas 'PointedEars' Lahn wrote: >> >> IBTD. A user-defined `constructor' property of the prototype of an >> >> object can be most useful. One basic principle of OOP is >> >> polymorphism, and one method of achieving that is overloading; that >> >> is, a method is defined on an object that is also defined on a >> >> superordinate object (in class-based OOP: the superclass; in >> >> prototype-based OOP: the next object in the prototype chain). (...) >> > >> > The need to access a superclass in order to achieve polymorphism is >> > ~non-inexistent, for in a weakly typed language such as JS a single >> > method is usually enough -> there's no need to overload anything, nor >> > access a superclass. >> >> A need that you are unable to perceive is still a need. I am using this >> pattern to my advantage, with the exception... > > ...that it has nothing to do with polymorphism. Yes, it has. "In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface. [...]" (en.Wikipedia) If a method is named the same for an object as for a superordinate object, so that the object's method performs only the tasks specific to the object, calling the superordinate's object to perform the more general tasks specific to object's derived from that superordinate object/class before, then that is one rather important application of polymorphism as it allows for API consistency and code re-use. You don't know what you are talking about, or you are unable to read and understand English. Probably both. >> of the use of the word "superclass" (as there are no classes). > > (loud applause) Idiot. The part before belongs *here*. Thus my wording was obviously referring to ECMAScript-comforming programming, applying your wording "with the exception of the use of the word 'superclass'" (as there are no classes in the ECMAScript implementations I was talking about). >> > And, in any case, in order for a method "method" of an instance "this" >> > to access its superclass' method "method", there's no need to use >> > neither "this.__proto__", nor this.constructor, nor >> > this.constructor.prototype, nor an "explicit constructor's >> > identifier". >> >> Then, pray tell, how would you call it then > > Think again. (hint: you want to let the prototype chain do its thing) Power-on your own brain for a change. If you *overload* the prototype's (or in class-based OOP: the superclass's) method, *and* you want to reuse it, you need a way to call it because the method identifier now refers to the inheriting object's method. And if you used that without break condition ... So you do need a way to refer to the prototype, preferably a simple one that is easy to maintain. Example in a prototype-based ECMAScript implementation: function C() { } C.prototype.foo = function() { /* More general statements, to be re-used */ }; var o = new C(); o.foo = function() { /* * Pray call C.prototype.foo() here without referring * to the constructor or the prototype object */ /* Specialized statements */ }; o.foo(); Example in a class-based ECMAScript implementation (I could also have chosen Java or PHP or Python or ...): class Super { protected function foo() { /* More general statements, to be re-used */ } } class Sub extends Super { protected function foo() { /* JScript .NET has `super' to refer to the superclass */ super.foo(); /* Specialized statements */ } } var o : Sub = new Sub(); o.foo(); PointedEars -- Danny Goodman's books are out of date and teach practices that are positively harmful for cross-browser scripting. -- Richard Cornford, cljs, <cife6q$253$1$8300dec7(a)news.demon.co.uk> (2004) |