Java: how to name boolean properties

Posted by NoozNooz42 on Stack Overflow See other posts from Stack Overflow or by NoozNooz42
Published on 2010-05-31T17:27:00Z Indexed on 2010/05/31 17:33 UTC
Read the original article Hit count: 291

Filed under:
|
|

I just had a little surprise in a Webapp, where I'm using EL in .jsp pages.

I added a boolean property and scratched my head because I had named a boolean "isDynamic", so I could write this:

<c:if test="${page.isDynamic}">
   ...
</c:if>

Which I find easier to read than:

<c:if test="${page.dynamic}">
   ...
</c:if>

However the .jsp failed to compile, with the error:

javax.el.PropertyNotFoundException: Property 'isDynamic' not found on type com...

I turns out my IDE (and it took me some time to notice it), when generating the getter, had generated a method called:

isDynamic()

instead of:

getIsDynamic()

Once I manually replaced isDynamic() by getIsDynamic() everything was working fine.

So I've got really two questions here:

  1. is it bad to start a boolean property's name with "is"?

  2. wether it is bad or not, didn't IntelliJ made a mistake here by auto-generating a method named isDynamic instead of getIsDynamic?

© Stack Overflow or respective owner

Related posts about java

Related posts about jsp