循环依赖 [英] Circular dependencies
问题描述
我有2个项目。
项目#2引用了项目#1
Project#2 has a reference to Project#1
现在我需要在Project#1中引用Project#2,但是vsnet抱怨循环依赖。
Now I need to reference Project#2 in Project#1, but vs.net is complaining about a circular dependency.
有没有办法?
推荐答案
绝对不是。循环依赖性表示设计不良。我不是要苛刻。有一些方法。
Absolutely not. Circular dependencies are a indication of bad design. I don't mean to be harsh. There are some ways out of this.
1)您可以将常见代码重写为另一个项目,说项目#0
1) You can refactor common code to another project, say Project#0
2)你可以修改你的设计,这可能是要走的路。
2) You can fix your design, which is probably the way to go.
Bob叔叔有一篇关于包装原则的好文章,其中包括非循环依赖原则。 http://www.objectmentor.com /resources/articles/granularity.pdf 。阅读这个知道为什么循环依赖是一件坏事。
Uncle Bob has a good article on Packaging Principles which includes the Acyclic Dependencies Principle. http://www.objectmentor.com/resources/articles/granularity.pdf. Read this to know why cyclic dependencies are a bad thing.
这篇关于循环依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!