What is GetSet ?

GetSet is a solution for the getter/setter hell. It's composed by practice and some tools.

The Problem

The developper complaints about "getter and setter boilerplate".

  • noise in the source (see Here)
  • overkill

    Igor Vaynberg : "99% of these getters/setters are just boiler plate passthroughs to the property. People still create them because there might be an off chance that in the future you will need to add some behavior and it would be much harder to refactor a field into getter/setter combo."

  • waste of time (to produce, to read, to maintain, ... to keep in sync (name, type, comments,...))

For details, follow some links that expose the problem (and some solutions,...)

Our Solution

To avoid getter/setter boilerplate, we don't try to resolve the problem of how to generate get and set methods, but we try resolve the cause of using them : encapsulate attributes to provide the following benefits :

  • Reducing impact on caller when the internale structure changes (eg: age -> birth date)
  • Providing special behaviour when caller access property : read-only, write-only, notify changes, check value to set,... control the access to the payload of the object.

So our solution is to avoid getter and setter, in order to provide at less the same benefits :

  • Using public attribute as property (like lot of people suggest), cover more than 80% of usages.
  • Using GetAndSetAdder to generate basic public getter/setter on bytecode if need by framework/lib (optionnal)
  • Using AOP when you need to add extra stuff before/after reading/writing attribute (optionnal)

We provide a modular solution, simple for common case, and more complex for other case (with other benefits).

See Faq to learn why it's a working/viable solution.

See others approaches to compare.