It’s for scope, so that the list is accessible outside of the function that
created it; any local variables in the constructor (or any other method) for
tweets.MainWindow are not accessible outside of that function, so you have to
store them as a member value (e.g. this.__list). In the example, the getList()
method is the accessor method which makes the value available to the users of
the MainWindow class
I’m guessing you’ve previously used the design pattern where class methods are
declared in the constructor, e.g.:
function MyClass() {
var someLocalVar = “123";
this.myMethod = function() {
console.log(someLocalVar);
}
}
You can browse the full source at
https://github.com/qooxdoo/qooxdoo/blob/release_4_1/component/tutorials/tweets/step3/source/class/tweets/MainWindow.js
John
> On 28 Jan 2015, at 18:56, voger <[email protected]> wrote:
>
> I am going through the twitter tutorial located here
> http://manual.qooxdoo.org/current/pages/desktop/tutorials/tutorial-part-1.html
>
> and there the author changes the list declaration from var list = new
> qx.ui.form.List() to this.__list = new qx.ui.form.List().
>
> What is the reason for this change. Why should it change from simple
> variable to property? The accessor method
>
> getlist: function(){
> return this.__list;
> }
>
> wouldn't work the same if __list was a simple variable?
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel