[dojo-contributors] dojo.lang.inherits

Scott J. Miles sjmiles at turbophp.com
Wed Apr 5 20:33:22 EDT 2006

dojo.defineClass(subclass, superclass, { constructor: ..., param1: ...,
func1: ... });


Scott J. Miles
TurboAjax Group

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

>> 2. there is no separation between constructor initialization and 
>> instance 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 better 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: ... });

> I'd be interested in your thoughts on this:
> http://dean.edwards.name/weblog/2006/03/base/
> I wrote it to alleviate some of the problems you refer to below.
> -dean

Yeah, there was some discussion about this and some objections about not
staying true to javascript, but I didn't really understand it.  (The current
dojo stuff is just a thin wrapper on top of javascript and people wanted to
keep it that way, but not sure why.  Maybe just philosophical reasons.)
Hopefully someone can explain in more detail.


> On 5 Apr 2006, at 23:51, Scott J. Miles wrote:
> At the Dojo meeting today (4/5/2006), dojo.inherits came up and we 
> agreed to open up the discussion to the general contribs list.
> There are two (arguable) faults in the dojo.inherits implementation:
> 1. invoking super class methods is wordy and inconvenient.
> 2. there is no separation between constructor initialization and 
> instance initialization.
> There is general agreement that we want to 'let JS be JS'.
> With regard to (2), my personal opinion is that JS doesn't have an axe 
> to grind with respect to initialization, and there is nothing un-JS 
> about supporting a systemic instance initialization function (that is 
> to say, a standard way of specifying an instance initializer).
> Alex seemed right-away to have an idea of how tweak dojo.inherits to 
> add such a feature (yay). We briefly discussed adding additional 
> parameters to inherits vs. a key-word style signature. I prefer the 
> former, but there was no general agreement.
> 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.
> Re (1), nobody seemed to have a handle on how to make calling 
> inherited/parent/base-class methods easier. Morris has developed his 
> own inheritence system that may provide a solution.
> Thanks for listening. :)
> Regards,
> Scott J. Miles
> TurboAjax Group
> http://www.turboajax.com

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