Reputation: 3165
Why is the JavaBean standard set to use the prefix is- for a getter instead of get-?
It seems to be a really out place for a uniform naming convention, especially for only a single getter for a single type.
Upvotes: 0
Views: 405
Reputation: 89169
You can have "get" on a boolean too, it's allowed. I think they did this for readability. you say
if (bean.isImmutable()) { // Better
rather than
if (bean.getImmutable()) { //Get what?
Also, if you use reflection on JavaBeans and you see a getter method starting with a "is", you can do a type check to see if the return type of this getter method is a boolean (because only boolean have the special case of "is" getter method).
Upvotes: 4
Reputation: 6969
Reads better. Compare:
or even
Upvotes: 6