循环依赖 [英] Circular dependencies

查看:138
本文介绍了循环依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个项目。

项目#2的参考到项目#1

Project#2 has a reference to Project#1

现在我需要引用项目#2#项目1,但vs.net抱怨循环依赖。

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)您可以重构共同code到另一个项目,项目说#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大叔对包装原则的好文章,其中包括非循环依赖原则。 <一href=\"https://web.archive.org/web/20100102145126/http://objectmentor.com/resources/articles/granularity.pdf\"相对=nofollow> http://www.objectme​​ntor.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆