【发布时间】:2015-09-13 15:57:05
【问题描述】:
final String outputDir = ctxt.getOptions().getScratchDir().getAbsolutePath();
Demeter 法则说 C 类的方法 f 应该只调用这些方法:
- C
- 由 f 创建的对象
- 作为参数传递给 f 的对象
- 保存在 C 的实例变量中的对象
【问题讨论】:
-
这一定是我见过的最糟糕的“法律”.. :} 不管怎样,"an object should avoid invoking methods of a member object returned by another method."。如何避免这种违规或“改进”代码而不使其不必要地变得更复杂或只是将违规推到其他地方..我不知道。
标签: coding-style