PDA

View Full Version : Difference between attributes and class members...


paou
04-04-2006, 02:25 AM
Hi,

A quick question, Apologies in advance if I'm just blind and can't see it in the docs....

what's the difference between "attributes" and class members?

I find myself sometimes using attributes to store class specific data, and sometimes I just add a variable in the oninit handler... are these two concepts the same?

for example, the two following classes appear functionally the same.... My question is... are they physically the same? if not, how do I declare class members, doing so in the oninit handler seems messy. But I'm not so sure attrubutes are the same thing.


<class name="foo">
<handler name="oninit">
this.somePropertyArray = new Array();
</handler>

<method name="addproperty" args="x">
this.somePropertyArray.push(x);
</method>
</class>


<class name="bar">
<attribute name="somePropertyArray" type="expression" value="new Array()"/>

<method name="addproperty" args="x">
this.somePropertyArray.push(x);
</method>
</class>