How does inheritance actually work in QooxDoo?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How does inheritance actually work in QooxDoo?

dcipher
Hi

I created several custom classes one was a sub-class of the
qx.data.store.Json and another was a sub-class of qx.ui.form.TextField
and in the Chrome debugger's command window I did:

loS = new dcbase.stoJson()
loT = new dcbase.txtStd()

I then looked at the instances created and noticed that none of my
custom members were showing.  However everything was showing on __proto__.

Why are my additional members not shown on the object?  I would have
thought that they would be automatically applied to the instance.  Since
they are not then the normal javascript process kicks in and adds them
to the instance when their value is set in code.  That means if I read
the values in code before anything has been set I am actually reading
the prototype which is not what I want.

Can someone clarify how this works or where my understanding is lacking?

Thanks,
Simon



------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: How does inheritance actually work in QooxDoo?

Tino Butz-2
Hi Simon,

We do normal JS inheritance - no magic here ;)

Perhaps you can have a look on this great slides, to get a better understanding of JS / prototypes / inheritance:


Tino


Am 27.01.2012 um 14:31 schrieb Simon White:

Hi

I created several custom classes one was a sub-class of the
qx.data.store.Json and another was a sub-class of qx.ui.form.TextField
and in the Chrome debugger's command window I did:

loS = new dcbase.stoJson()
loT = new dcbase.txtStd()

I then looked at the instances created and noticed that none of my
custom members were showing.  However everything was showing on __proto__.

Why are my additional members not shown on the object?  I would have
thought that they would be automatically applied to the instance.  Since
they are not then the normal javascript process kicks in and adds them
to the instance when their value is set in code.  That means if I read
the values in code before anything has been set I am actually reading
the prototype which is not what I want.

Can someone clarify how this works or where my understanding is lacking?

Thanks,
Simon



------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Tino Butz
Mobile Architect

1&1 Internet AG - Web Technologies
Ernst-Frey-Straße 9 · DE-76135 Karlsruhe
Telefon: +49 721 91374-4488

Amtsgericht Montabaur / HRB 6484
Vorstände: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Robert Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr. Oliver Mauss, Jan Oetjen
Aufsichtsratsvorsitzender: Michael Scheeren


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: How does inheritance actually work in QooxDoo?

dcipher
Hi

The problem I encountered that raised this question was that I created a
sub class of the Json store and added an array member called
changedItems and set it to an empty array.  I expected each instance of
this subclass to have its own copy of the array.  However I found that
this array only existed on the prototype which caused a number of
problems.  Namely changed items being sent to the wrong table in the
database because each store was sharing the same array.

Simon

On 31/01/2012 5:40 AM, Tino Butz wrote:

> Hi Simon,
>
> We do normal JS inheritance - no magic here ;)
>
> Perhaps you can have a look on this great slides, to get a better
> understanding of JS / prototypes / inheritance:
>
> http://www.slideshare.net/Sampetruda/advanced-javascript-closures-prototypes-and-inheritance
>
> Tino
>
>
> Am 27.01.2012 um 14:31 schrieb Simon White:
>
>> Hi
>>
>> I created several custom classes one was a sub-class of the
>> qx.data.store.Json and another was a sub-class of qx.ui.form.TextField
>> and in the Chrome debugger's command window I did:
>>
>> loS = new dcbase.stoJson()
>> loT = new dcbase.txtStd()
>>
>> I then looked at the instances created and noticed that none of my
>> custom members were showing. However everything was showing on __proto__.
>>
>> Why are my additional members not shown on the object? I would have
>> thought that they would be automatically applied to the instance. Since
>> they are not then the normal javascript process kicks in and adds them
>> to the instance when their value is set in code. That means if I read
>> the values in code before anything has been set I am actually reading
>> the prototype which is not what I want.
>>
>> Can someone clarify how this works or where my understanding is lacking?
>>
>> Thanks,
>> Simon
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Try before you buy = See our experts in action!
>> The most comprehensive online learning library for Microsoft developers
>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>> Metro Style Apps, more. Free future releases when you subscribe now!
>> http://p.sf.net/sfu/learndevnow-dev2
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
> Tino Butz
> Mobile Architect
>
> 1&1 Internet AG - Web Technologies
> Ernst-Frey-Straße 9 · DE-76135 Karlsruhe
> Telefon: +49 721 91374-4488
> [hidden email] <mailto:[hidden email]>
>
> Amtsgericht Montabaur / HRB 6484
> Vorstände: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Robert
> Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr. Oliver Mauss, Jan Oetjen
> Aufsichtsratsvorsitzender: Michael Scheeren
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
>
>
>
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: How does inheritance actually work in QooxDoo?

Tristan Koch
Hi Simon,

we have a section in our manual that explains why reference types should not be used in the members section. Perhaps you can take a loot at the page and give us some feedback if our explanation is helpful.

http://manual.qooxdoo.org/1.6.x/pages/core/classes.html#primitive-types-vs-reference-types

Basically, for fields holding reference types the procedure is to initialize with null (for documentation purposes) and later, in the constructor, assign a property on the object that is being created (rather than its prototype).

Regards
Tristan

Am 31.01.2012 um 22:53 schrieb Simon White:

> Hi
>
> The problem I encountered that raised this question was that I created a
> sub class of the Json store and added an array member called
> changedItems and set it to an empty array.  I expected each instance of
> this subclass to have its own copy of the array.  However I found that
> this array only existed on the prototype which caused a number of
> problems.  Namely changed items being sent to the wrong table in the
> database because each store was sharing the same array.
>
> Simon
>
> On 31/01/2012 5:40 AM, Tino Butz wrote:
>> Hi Simon,
>>
>> We do normal JS inheritance - no magic here ;)
>>
>> Perhaps you can have a look on this great slides, to get a better
>> understanding of JS / prototypes / inheritance:
>>
>> http://www.slideshare.net/Sampetruda/advanced-javascript-closures-prototypes-and-inheritance
>>
>> Tino
>>
>>
>> Am 27.01.2012 um 14:31 schrieb Simon White:
>>
>>> Hi
>>>
>>> I created several custom classes one was a sub-class of the
>>> qx.data.store.Json and another was a sub-class of qx.ui.form.TextField
>>> and in the Chrome debugger's command window I did:
>>>
>>> loS = new dcbase.stoJson()
>>> loT = new dcbase.txtStd()
>>>
>>> I then looked at the instances created and noticed that none of my
>>> custom members were showing. However everything was showing on __proto__.
>>>
>>> Why are my additional members not shown on the object? I would have
>>> thought that they would be automatically applied to the instance. Since
>>> they are not then the normal javascript process kicks in and adds them
>>> to the instance when their value is set in code. That means if I read
>>> the values in code before anything has been set I am actually reading
>>> the prototype which is not what I want.
>>>
>>> Can someone clarify how this works or where my understanding is lacking?
>>>
>>> Thanks,
>>> Simon
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Try before you buy = See our experts in action!
>>> The most comprehensive online learning library for Microsoft developers
>>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>>> Metro Style Apps, more. Free future releases when you subscribe now!
>>> http://p.sf.net/sfu/learndevnow-dev2
>>> _______________________________________________
>>> qooxdoo-devel mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>
>> Tino Butz
>> Mobile Architect
>>
>> 1&1 Internet AG - Web Technologies
>> Ernst-Frey-Straße 9 · DE-76135 Karlsruhe
>> Telefon: +49 721 91374-4488
>> [hidden email] <mailto:[hidden email]>
>>
>> Amtsgericht Montabaur / HRB 6484
>> Vorstände: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Robert
>> Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr. Oliver Mauss, Jan Oetjen
>> Aufsichtsratsvorsitzender: Michael Scheeren
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Keep Your Developer Skills Current with LearnDevNow!
>> The most comprehensive online learning library for Microsoft developers
>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>> Metro Style Apps, more. Free future releases when you subscribe now!
>> http://p.sf.net/sfu/learndevnow-d2d
>>
>>
>>
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: How does inheritance actually work in QooxDoo?

dcipher
Hi

That explanation is helpful and I know I must have read it but then
still made this mistake.  So I have no one to blame but myself and
thank-you for pointing this out in the manual again. I have definitely
learned my lesson!

Thanks,
Simon



On 01/02/2012 5:52 AM, Tristan Koch wrote:

> Hi Simon,
>
> we have a section in our manual that explains why reference types should not be used in the members section. Perhaps you can take a loot at the page and give us some feedback if our explanation is helpful.
>
> http://manual.qooxdoo.org/1.6.x/pages/core/classes.html#primitive-types-vs-reference-types
>
> Basically, for fields holding reference types the procedure is to initialize with null (for documentation purposes) and later, in the constructor, assign a property on the object that is being created (rather than its prototype).
>
> Regards
> Tristan
>
> Am 31.01.2012 um 22:53 schrieb Simon White:
>
>> Hi
>>
>> The problem I encountered that raised this question was that I created a
>> sub class of the Json store and added an array member called
>> changedItems and set it to an empty array.  I expected each instance of
>> this subclass to have its own copy of the array.  However I found that
>> this array only existed on the prototype which caused a number of
>> problems.  Namely changed items being sent to the wrong table in the
>> database because each store was sharing the same array.
>>
>> Simon
>>
>> On 31/01/2012 5:40 AM, Tino Butz wrote:
>>> Hi Simon,
>>>
>>> We do normal JS inheritance - no magic here ;)
>>>
>>> Perhaps you can have a look on this great slides, to get a better
>>> understanding of JS / prototypes / inheritance:
>>>
>>> http://www.slideshare.net/Sampetruda/advanced-javascript-closures-prototypes-and-inheritance
>>>
>>> Tino
>>>
>>>
>>> Am 27.01.2012 um 14:31 schrieb Simon White:
>>>
>>>> Hi
>>>>
>>>> I created several custom classes one was a sub-class of the
>>>> qx.data.store.Json and another was a sub-class of qx.ui.form.TextField
>>>> and in the Chrome debugger's command window I did:
>>>>
>>>> loS = new dcbase.stoJson()
>>>> loT = new dcbase.txtStd()
>>>>
>>>> I then looked at the instances created and noticed that none of my
>>>> custom members were showing. However everything was showing on __proto__.
>>>>
>>>> Why are my additional members not shown on the object? I would have
>>>> thought that they would be automatically applied to the instance. Since
>>>> they are not then the normal javascript process kicks in and adds them
>>>> to the instance when their value is set in code. That means if I read
>>>> the values in code before anything has been set I am actually reading
>>>> the prototype which is not what I want.
>>>>
>>>> Can someone clarify how this works or where my understanding is lacking?
>>>>
>>>> Thanks,
>>>> Simon
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Try before you buy = See our experts in action!
>>>> The most comprehensive online learning library for Microsoft developers
>>>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>>>> Metro Style Apps, more. Free future releases when you subscribe now!
>>>> http://p.sf.net/sfu/learndevnow-dev2
>>>> _______________________________________________
>>>> qooxdoo-devel mailing list
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>>
>>> Tino Butz
>>> Mobile Architect
>>>
>>> 1&1 Internet AG - Web Technologies
>>> Ernst-Frey-Straße 9 · DE-76135 Karlsruhe
>>> Telefon: +49 721 91374-4488
>>> [hidden email]<mailto:[hidden email]>
>>>
>>> Amtsgericht Montabaur / HRB 6484
>>> Vorstände: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Robert
>>> Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr. Oliver Mauss, Jan Oetjen
>>> Aufsichtsratsvorsitzender: Michael Scheeren
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Keep Your Developer Skills Current with LearnDevNow!
>>> The most comprehensive online learning library for Microsoft developers
>>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>>> Metro Style Apps, more. Free future releases when you subscribe now!
>>> http://p.sf.net/sfu/learndevnow-d2d
>>>
>>>
>>>
>>> _______________________________________________
>>> qooxdoo-devel mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Keep Your Developer Skills Current with LearnDevNow!
>> The most comprehensive online learning library for Microsoft developers
>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>> Metro Style Apps, more. Free future releases when you subscribe now!
>> http://p.sf.net/sfu/learndevnow-d2d
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d



------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel