以外行人的术语描述.NET程序集循环依赖问题 [英] Describe the .NET assembly circular dependency problem in layman's terms

查看:197
本文介绍了以外行人的术语描述.NET程序集循环依赖问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请注意:这似乎是一个简单的问题,我是知道,但我已经看到一些真正重要的项目完全破坏依赖关系图。

解决方案

添加到Lucas的答案:很难在.NET中找到一个循环的程序集依赖关系。为了编译 A.dll 你首先需要 B.dll ;编译 B.dll 你首先需要 C.dll ;但要编译 C.dll 您需要 A.dll 您首先尝试编译。 p>

您可能会遇到这种情况的唯一方法是如果您正在平行开发A,B和C,并且您已经设法引入了循环依赖事故。但是,一旦你完成了所有这三个工作的清理工作,这个问题就会显而易见,在你打破周期之前你将无法继续。



命名空间和/或单个依赖关系中的类之间的依赖关系更为常见。我试图把这种循环依赖看作一个代码气味;没有组件之间的循环依赖关系的代码库是这些组件可以轻松地独立存储并独立重构的代码库。



Patrick Smacchia(NDepend的人)谈到一些关于依赖循环和它们对代码质量的影响在这里: http ://codebetter.com/blogs/patricksmacchia/archive/2009/07/29/maintainability-learnability-component-layering.aspx


Please describe the .NET assembly compilation circular dependency problem in layman's terms, and whether other technologes have similar limitations.

Note: This seems like a simple question, I know, but I have seen a number of real, significant projects that have totally broken dependency graphs.

解决方案

To add to Lucas's answer: it's very hard to come up with a circular assembly dependency in .NET. In order to compile A.dll you first need B.dll; to compile B.dll you first need C.dll; but to compile C.dll you need the A.dll you were trying to compile in the first place.

The only way you're likely to get into this situation is if you're developing A, B and C in parallel, and you've managed to introduce a circular dependency by accident. But as soon as you do a clean build of all three, the problem will be apparent, and you won't be able to proceed until you break the cycle.

Circular dependencies between namespaces and/or classes within a single dependency are a lot more common. I try to treat this kind of circular dependency as a code smell; a codebase without circular dependencies between components is one where those components can easily be kept separate and refactored independently.

Patrick Smacchia (the NDepend guy) talks a little about dependency cycles and their effect on code quality here: http://codebetter.com/blogs/patricksmacchia/archive/2009/07/29/maintainability-learnability-component-layering.aspx

这篇关于以外行人的术语描述.NET程序集循环依赖问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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