3 ms·
I think this idea is that you can use "properties" rather than public class variables. Then you can convert your public vars into properties at a later date.
by jiggy2011 15y ago
I think this idea is that you can use "properties" rather than public class variables.
Then you can convert your public vars into properties at a later date.
This means that you will not have to (necessarily) rewrite your code as the language knows that
a = myobj.myvar
now should call getmyvar() in the containing class and:
myob.myvar = a
should call setmyvar(a) , I know that C# certainly allows this.
- esrauch 15y agoC# allows it but but Java doesn't have this. Hence why it's standard operating procedure to just use setters from the beginning, because it might be nontrivial to update all references.
- jiggy2011 15y agoPlay! framework allows you to use getters and setters with public members as you would in C#. Not sure how this is implemented.
- aaimnr 15y agoSpring Roo does the same through the use of aspect programming (code generation, essentially - it generates the boilerplate behind the scenes).