There is no better way for a part of the language - nothing like the keyword "property".
One alternative, as other people have said, is to use your IDE to create them. Another, if you have many objects that need it, is to write your own code generation tool that takes a base class and creates a wrapper with getters and setters.
You can also just set the variables as public. However, on the way this will probably come back to hurt you when you decide to add validation logic.
However, one final thought: if your classes are not just used for data transfer, they probably should not reveal their internal state. IMO, getter and setter classes of behavior are code smells.
kdgregory Dec 15 '09 at 13:14 2009-12-15 13:14
source share