可以将 class 实现与其接口硬耦合吗?

Is it ok to Hard Couple a class implementation with its interface?

我试图理解其他人的代码,但我在关于如何创建构建器的实现中看到了一些非常奇怪的东西。这个设计好不好?

public interface Car {
 static Builder createBuilder() {
     return new CarImpl.Builder();
 }
 interface Builder {
  /// Setters contract
 }
}

通常不,您的界面应该定义 class 的行为(函数的签名),例如在 'Car' 中公开驱动、停止、加油等函数

您的界面不应该知道实现细节。 这是接口背后的想法——它抽象出实现细节,因此它们被封装在负责实现的任何层中,这使您的接口保持干净,只公开内容而不公开方法。