views:

928

answers:

2

I know most variable names will work with "is", such as isBlue, but is "has" also a valid prefix, like hasProperty?

+1  A: 

This is somewhat subjective, but yes, I would say "has" is a perfectly valid prefix for a Boolean property.

edit the question, as asked, did not mention the javabeans specification and so my answer did not address that aspect of the question. Hence the answer above.

Ryan Guill
It's not subjective - it's determined by the JavaBeans specification.
Jon Skeet
And yet he did not mention that in his question that he was looking for an answer that worked for the javabeans specification.
Ryan Guill
Is "valid java beans names" in the subject not a pretty big clue?
Jon Skeet
I would argue no. I am just suggesting that someone, either you or the original author edit the question to make it more clear. It would also make it more likely to be found using a search engine and make the question more useful.
Ryan Guill
@Ryan - There's a reason why He is "Jon Skeet" and we are not :-)
Jose Basilio
yes, and I suspect that that fact alone is enough for everyone to agree with him. I was confused by the question because it wasn't clear and can see no reason not to edit the question for clarity. Oh well.
Ryan Guill
I shall leave that to the author - if you think there is doubt as to whether the question is really talking about "proper" JavaBeans, it would be wrong for me to put the words into the author's mouth.
Jon Skeet
+6  A: 
Jon Skeet
This answer makes perfect sense, but I would say that the question needs to be reworded to mention that the question is specific to the javabeans specification. The tags alone do not convey that information well enough and generally speaking, according the question itself, "has" would be a perfectly acceptable prefix.
Ryan Guill
The subject line makes it fairly clear IMO - and the fact that he asks whether a variable name will "work" suggests there's something more than just personal preference involved here.
Jon Skeet