为什么命名空间类型不应该依赖嵌套的命名空间类型? [英] why namespace types should not depend on nested namespaces types?

查看:90
本文介绍了为什么命名空间类型不应该依赖嵌套的命名空间类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.Net命名准则中( http: //msdn.microsoft.com/zh-CN/library/893ke618(v=vs.71).aspx )的语句如下:

In .Net naming guidelines (http://msdn.microsoft.com/en-us/library/893ke618(v=vs.71).aspx) there is this statement:

"嵌套的名称空间应依赖于包含的名称空间中的类型.例如,System.Web.UI.Design中的类取决于System.Web.UI中的类.但是,System中的类. Web.UI不依赖于System.Web.UI.Design中的类."

"A nested namespace should have a dependency on types in the containing namespace. For example, the classes in the System.Web.UI.Design depend on the classes in System.Web.UI. However, the classes in System.Web.UI do not depend on the classes in System.Web.UI.Design."

我想知道:为什么?

推荐答案

因为考虑到这一点很有意义.

Because it makes sense when you think about it.

让我用一个小例子来说明:

Let me explain with a small example:

例如,

一个刀片需要一个手柄才能成为 刀".

A knife-blade for example needs a handle for it to be a "knife".

但是手柄不是,需要用小刀作为手柄,对吗?

But a handle doesn't need a knife-blade to be a handle, correct?

using KitchenSet;
using KitchenSet.Knives; // This is where your knives (what uses Blades) would live.
using KitchenSet.Knives.Blades; // The actual blades. 

这篇关于为什么命名空间类型不应该依赖嵌套的命名空间类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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