The following methods are implemented in an abstract base class, that is extended by many subclasses:
public final void doSomething() {
if( hasBehavior1() ) {
// special behavior
}
if( hasBehavior2() ) {
// special behavior
}
// do other things
}
protected abstract boolean hasBehavior1();
protected abstract boolean hasBehavior2();
How should I name these methods hasBehaviorX() for the cases that the special behavior is
- to encrypt some data?
- to ignore an error?
- to check for correctness?
The special behavior is too easy to use a different implementation pattern like the strategy pattern, so I’m really looking for some useful naming conventions here.
I found a way to express the special behavior by using the java conventions for boolean members with the verb in its present progressive form: