1

私はいくつかの古いコードを調べていて、テンプレート メソッドの実装で次の命名規則を見つけました。

// 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);

フック メソッドの名前は、 acceptImpl()ではなく、doAccept ()またはacceptHook()になると思います。

「-Impl」サフィックスはフックメソッドに実際に使用されていますか? または紛らわしい命名慣行ですか?

4

1 に答える 1