【发布时间】:2011-11-09 19:03:04
【问题描述】:
许多文章/书籍/.. 谈论类或包依赖,很少解释它是什么。我确实找到了一些定义,但它们各不相同,可能并不涵盖所有情况。例如:
- "when one class uses another concrete class within its implementation"(所以不存在对接口的依赖?)
- "when a class uses another as a variable"(继承呢?)
- "if changes to the definition of one element may cause changes to the other"(所以依赖关系是一种传递关系,不仅在包上,而且在类级别上?)
- "the degree to which each program module relies on each one of the other modules"(但你如何定义“依赖”?)
要考虑的其他方面是方法参数、依赖注入、面向方面的编程、泛型。还有其他方面吗?
那么,你能否给出一个(正式的)类之间和包之间的依赖关系的定义,它是万无一失的,并且涵盖了所有这些情况和方面?
【问题讨论】:
-
你想解决什么问题?
-
@bancer:不是一个特别的问题,只是总体上改进我的(干净代码)开发,例如通过遵循 Bob 叔叔的建议,了解所涉及的指标(例如 jdepend 中给出的),以及各种依赖注入。
标签: oop architecture dependencies