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
2009-04-28 18:32:57
It's not subjective - it's determined by the JavaBeans specification.
Jon Skeet
2009-04-28 18:39:30
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
2009-04-28 18:42:45
Is "valid java beans names" in the subject not a pretty big clue?
Jon Skeet
2009-04-28 18:44:29
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
2009-04-28 18:53:51
@Ryan - There's a reason why He is "Jon Skeet" and we are not :-)
Jose Basilio
2009-04-28 18:54:55
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
2009-04-28 18:57:02
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
2009-04-28 18:57:38
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
2009-04-28 18:41:41
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
2009-04-28 18:45:12