[dojo-contributors] dojo.lang.inherits

Scott J. Miles sjmiles at turbophp.com
Wed Apr 5 21:13:45 EDT 2006

It's easy to get into religious warfare about inheritence models. I'm pretty
confident that practicality and laziness trump philosophical issues,
generally. That is to say, the requested feature is simply useful and is not
intended as a way to cram JS into some non-native oop model. 

I tried to ameliorate this reaction in my original post via these
> There is general agreement that we want to 'let JS be JS'.
I still say that there is nothing un-JS about having an instance
initializer. Calling a constructor is required to produce a prototype, so
there is an inherent limitation to what you can achieve in pure constructors
(without conditional cruft).

> There was some talk about the term 'inherits' implying a non-JS idiom, but

> this is not a problem IMO. Any suggestions for new nomenclature are
> appreciated.

I have successfully avoided Java, so any similarities there are just tragic

Scott J. Miles
TurboAjax Group

From: dojo-contributors-bounces at dojotoolkit.org
[mailto:dojo-contributors-bounces at dojotoolkit.org] On Behalf Of Jesse
Sent: Wednesday, April 05, 2006 5:31 PM
To: dojo dev.
Subject: Re: [dojo-contributors] dojo.lang.inherits

I guess I'm being mr. grumpy today, but I had a small thought on this..

I think it's a mistake for dojo devs or users to think of anything going on
in dojo as analgous to another programming language, unless the similarities
are really close. (ie java/ c++ ) 

The problem with this I think is that when you open that door you find users
(like myself) that see words like "inheritance/constructors/etc" and start
to expect other things to behave like java as well. Like superclass
functions always being called on child classes. This can also lead to what I
think are "impure" thoughts when you're a developer. If you allow yourself
to slip back into thinking the way you did in another programming language
you're not really seeing the "matrix" of the language you're actually coding
in. If the dojo devs aren't see this supposed "matrix" then it seems like
innovation and cool new features that intuitively leverage the JS language
are less likely to come about as a result. 

On 4/5/06, Bill Keese <bill at dojotoolkit.org> wrote: 

	>> 2. there is no separation between constructor initialization and
	>> initialization.
	The suggestion is something similar to this, right?
	dojo.inherits(subclass, superclass, fnInit); 
	dojo.extends(subclass, { param1: ..., func1: ... } );
	(where fnInit is the constructor in the java sense of the word)
	This is really abusing the meaning of "inherit".  Wouldn't it be
	to combine these two functions into one function like this?
	dojo.defineClass(subclass, superclass, fnInit,
	  { param1: ..., func1: ... });
	As a matter of fact, Alex has already done this for widgets (see
	http://archive.dojotoolkit.org/nightly/src/widget/Dialog.js )
	PS: alternately you could use this syntax:
	dojo.defineClass(subclass, superclass, 
	        { constructor: ..., param1: ..., func1: ... });

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.5/301 - Release Date: 4/4/2006

More information about the dojo-contributors mailing list