[dojo-contributors] dojo.lang.inherits

Sandro Magi smagi at naasking.homeip.net
Thu Apr 6 18:15:02 EDT 2006

Tom Trenka wrote:
> Funny how?  Do I amuse you? Am I like a clown to you?
> :D
> OK, enough of the bad mafia jokes...so the key to JS is that the
> prototype, and searching through the prototype chain to find the first
> method or property signature (depending on scope definition) is what
> passes for inheritance in JS.  To call delegation the method of
> inheritance in JS is not an inaccurate statement (although it's
> deceptive)

It's descriptive in that a form of inheritance is achieved via delegation.

>, and that's one of the reasons (making assumptions in Alex's
> thinking here that might be wrong) Alex called it "delegate".
> Seriously though, this is one of the reasons why I was making the
> argument yesterday; it seems like there's a lot of people who come from
> C++/Java/C# backgrounds (not you, I've no idea what yours is) that think
> there should be a way of calling a super method in JS and get really
> frustrated when you can't.  And we can't really think about it the way
> C# does (I think that's what Bill was referring to); that's similar but
> not the same thing.

Exactly. The problem with using overloaded words like "inherit",
"interface", "mixin", and "class" is that people think that they're
dealing with an abstraction they're familiar with, when they're really
not. They then end up surprised when something doesn't work as expected.
Thus, try to avoid overloaded words, particularly the complex abstractions.

When programming in a particular environment (a prototype-based dynamic
language like Javascript), then familiarize yourself with that
environment. That's not too much of a stretch right? :-)


More information about the dojo-contributors mailing list