【问题标题】:What are proper names of delegate-enclosing classes?代表封闭类的专有名称是什么?
【发布时间】:2015-12-17 07:38:07
【问题描述】:

我有以下抽象类。

abstract class AbstractSome implements Interface1, Interface2 {
    // all methods defined in Interface1 is implemented
}

现在我想使用实现Interface2 的委托来扩展这个类。

class ????Some extends AbstractSome {

    public ????Some(final Interface2 delegate) {
        this.delegate = delegate;
    }

    @Override // defined in Interface2
    public void doSomething() {
        delegate.doSomething();
    }

    private final Interface2 delegate;
}

这个封闭类有什么好的naming-convention吗?

Delegating...Default... 好吗?

【问题讨论】:

  • 这似乎是基于意见的问题,但我希望看到一些好的回应。
  • 没有这样的约定。对于类抽象类 InMemoryFile 实现可读,可写我会调用这样的类 DelegateWriteInMemoryFile

标签: java delegates naming-conventions


【解决方案1】:

您使用的设计非常接近adapter pattern,所以我认为使用SomeAdapdterSomeDelegateAdapter 之类的类名将是一个好方法

我认为对于这种特殊情况没有命名约定

【讨论】:

    【解决方案2】:

    我坚持同样的问题,并得出结论 Delegator 最适合:

    来自CollinsDictionary

    委托人 -- 委托人

    【讨论】:

    • 还有一些人确实使用Delegating前缀。
    猜你喜欢
    • 2022-07-12
    • 1970-01-01
    • 1970-01-01
    • 2010-10-26
    • 2019-08-23
    • 1970-01-01
    • 1970-01-01
    • 2015-01-10
    • 2012-03-08
    相关资源
    最近更新 更多