Design rules 设计原则

  1. Keep configurable data at high levels.

  2. Prefer polymorphism to if/else or switch/case.

  3. Separate multi-threading code.

  4. Prevent over-configurability.

  5. Use dependency injection.

  6. Follow Law of Demeter. A class should know only its direct dependencies.

  • 配置性数据放在高层。

  • 采用多态代替if/else和switch/case。

  • 隔离多线程代码。

  • 不要过度可配置。

  • 使用DI(依赖注入)。

  • Demeter原则:父类不需要知道子类的实现。

Last updated

Was this helpful?