Please refer to Naming conventions for java methods that return boolean(No question mark)
to make a comparison about what I am NOT asking.
My question concerns properties derived from delegates embedded in a container object.
While the setters of all properties regardless of type is easily and conveniently prefixed with "set" (e.g. setValueRequired(blah) ), there are various types of boolean properties each whose getter is conventionally named {verb}{PropertyName}. e.g.,
- the most common is existential, by convention is prefixed by "is". e.g. isEmpty().
- possessive property, prefixed by "has", e.g. hasValue().
- affirming necessity, prefixed by "requires", e.g. requiresResize(), providesResize().
By far, most property getters are somehow converted into existential properties. e.g. isRequireResize, isValued, etc. Therefore, my question concerns only expressing existential boolean properties (of a delegate class).
Let us say the container class is Printer, which contains the class Queue.
class Queue {
boolean empty, resettable, resizable;
}
class Printer {
Queue queue;
}
How then should Printer name its delegated properties for Queue? Because the following, by English comprehension convention, is awkward, as they sound like asking a question, not affirming its status.
- isQueueEmpty()
- isQueueResettable()
- isQueueResizable()
The boolean property should be affirmative and not sound like asking a question. Therefore for comprehensible English, they should be
- queueIsEmpty()
- queueIsResettable()
- queueIsResizable()
Or alternatively, could be
- isEmptyQueue()
- isResettableQueue()
- isResizableQueue()
However, automated delegate method code generators invariably generate names isQueueEmpty(), isQueueResettable(), isQueueResizable().
That is awkward when placed into an if
if (isQueueResettable() && !isQueueEmpty()) resetQueue();
As this sounds better
if (isResizableQueue() && !isEmptyQueue()) resetQueue();
~
My Questions actually
If there a JSR recommending naming conventions of property getters? What is it? Certainly there must be, otherwise wouldn't all the code generators out there be limping around with ambiguous conventions?
If there is, does the JSR have recommendation for delegated boolean existential property getters?
If not JSR, at least some form of RFCs in Apache, JBoss, Eclipse, etc?
Don't you think the convention I recommend is better than code generators creating questioning getters?