jeudi 27 octobre 2016

Is the -Impl suffix a legitimate naming convention for a Hook method in Java?

I was going over some old code and found the following naming convention at a template method implementation.

// TEMPLATE METHOD
// Check condition and fail fast if condition is met.
// Otherwise call the hook method (to be implemented by subclasses).
@Override
public boolean accept(String text) {
    if (condition) {
        return false;
    }

    // call to the hook method. Each subclass implements its own logic
    return acceptImpl(text);
}

// HOOK METHOD
protected abstract boolean acceptImpl(String text);

I would expect the hook method to be named doAccept() or acceptHook() instead of acceptImpl().

Is the "-Impl" suffix used in practice for hook methods? or Is it a confusing naming practice?

Aucun commentaire:

Enregistrer un commentaire