pandaa/node.class — Issue #1: Automated Getters and Setters
Author: jhnns
Created: 2012-01-13 13:35:27+00:00
State: open

Public properties (that are not functions) can't be exposed, because booleans, strings and numbers are copied by value. Since a class exists of two objects - the instance itself and one, exposing only public functions -, copy by value one made the variables out of sync.

Furthermore having getters and setters is always a good idea.

It should look like this:
```javascript
// class definition
var SomeClass = new Class({
someString: "Hello, I'm a string"
});

// the exposing object will than be something like this
{
setSomeString: function (value) {
this.someString = value;
},
getSomeString: function () {
return this.someString;
}
}
```
It's **very important** that you access the variable within the class without a _-prefix, because the programmer has defined the variable like this. He would be surpised, that the variable is not available inside the class.

This means: Although the variable has no private prefix, it should be available only within the class. From the outside you access these variables via the getter and setter.

This should apply to **all** variables, even though Objects and Arrays are copied by reference. So the behaviour is consistent and predictable.