Force use of accessors? (getters & setters)
How to prevent/detect the incorrect direct use of properies in cf9 e.g.
aPerson.FirstName = "Rumplestiltskin";
...when a component is rewritten to use accessors e.g.
aPerson.setFirstName("Rumplestiltskin");
e.g. a component is changed from...
Component Person {
property name="FirstName" type="string";
}
...to...
Component Person accessors="true" {
property name="FirstName" type="string" getter="true" setter="true";
}
1) Is it possible to prevent the propeties being set directly?
e.g. This should cause an error:
aPerson.FirstName = "Rumplestiltskin";
In practice, properties can still be set directly even though the component has declared that accessors should be used. I want to make this illegal im my app.
2) Is it possible to prevent the use of undeclared properties?
e.g. This should cause an error:
aPerson.ChristianName = "Rumplestiltskin"; // non-existent property
or
aPerson.furstname = "Rumplestiltskin"; // Mis-spelt property
In practice, properties can be set even if they don't exist. I want to make this illegal im my app.
3) Is it possible to intercept the direct use of properties
e.g. when this is executed...
aPerson.FirstName = "Rumplestiltskin";
..the function aPerson.setFirstName() is called
This would make it possible to solve 1), or better still, make the app backwardly compatible.
When an app is rewritten to use accessors, I don't want to have to change every instance of
aPerson.FirstName = "Rumplestiltskin";
...to...
aPerson.setFirstName("Rumplestiltskin");
...or at least, I want to be told if I've missed one.
Thanks,
Julian
