我应该担心卫冕的命名空间数/长度/范围有多大? [英] Should I worry about reigning in namespace number/length/scope?

查看:132
本文介绍了我应该担心卫冕的命名空间数/长度/范围有多大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近改组的解决方案,在建的24个项目为4。

I've recently reorganized a solution-in-progress from 24 projects to 4.

要保持组织在主项目中的丰富的文件,事情是在文件夹中的文件夹的文件夹。我想我已经preserved解决方案内容的逻辑,发现安排。

To keep the copious files organized in the "main" project, things are in folders in folders in folders. I think I've preserved a logical, discoverable arrangement of the solution content.

这样一来,当然,我结束了类似的命名空间的 AppName.DataAccess.NHibernate.Fluent.Mappings

As a result, of course, I end up with namespaces like AppName.DataAccess.NHibernate.Fluent.Mappings.

有没有办法,我应该关心不上不下的命名空间层次结构的时候,我的项目有一个稍微深层嵌套的文件夹结构中的任何令人信服的理由?

(我不关心解决或管理使用指令;我让ReSharper的做所有的繁重这里)

推荐答案

我只会扁平化,其中有一个明显的优势,维护这样做的。

I would only flatten where there is a distinct maintenance advantage to do so.

名称空间是更用于组织目的是帮助减少命名冲突的额外益处。我倾向于把我的命名空间,符合.NET Framework和其他主要图书馆命名空间。这可以帮助其他人发现的类更加容易。 (正如你所说,发现排列)。例如,我的道路公用事业Missico.IO.Path下,Missico.Data在我的数据访问库,AppName.DataManager在我的应用程序的数据访问(使用Missico.Data和所有其他数据命名空间)。

Namespaces are more for organizational purposes with the added benefit of helping to reduce naming conflicts. I tend to keep my namespaces in-line with the .NET Framework and other major library namespaces. This helps others to find classes easier. (As you say, discoverable arrangement.) For instance, my path utilities are under Missico.IO.Path, my data access library under Missico.Data, my application's data access under AppName.DataManager (which uses Missico.Data and all other data namespaces).

我总是用我的姓或公司的名称在根命名空间。 (任何名词都行。)这使得用户(程序员)来轻松解决命名冲突有一个简单的名称改变源$ C ​​$ C或使用别名库引用。

I always use my last name or the company's name at the root namespace. (Any noun will do.) This allows the user (programmer) to easily resolve naming conflicts with a simple name change in source code or an using alias for library references.

using Company = Missico;
String x = Company.IO.Path.CommonPath("", "");

我尽量保持一个文件夹,每个命名空间。嵌套的文件夹,如果该命名嵌套。这有助于我和其他人找到源$ C ​​$ C更快,因为他们所熟悉的空间结构。为什么让他们学习两种结构。每个文件夹包含所有该命名空间的源文件,除了复杂的类。他们得到有自己的子文件夹(在不改变命名空间)。我最终可能包含四个或五个子文件夹复杂的类和支持类命名空间文件夹。

I try to keep a folder for each namespace. Nesting the folders if the namespaces are nested. This helps me and others to find source code quicker because they are familiar with the namespace structure. Why make them learn two structures. Each folder contains all the source files for that namespace, except for complex classes. They get there own subfolder (without changing the namespace.) I may end up with a namespace folder that contains four or five subfolders for complex classes and supporting classes.

请注意,由于定义系统命名空间会造成各种各样的麻烦,我用核心作为我的系统/全球的命名空间。

Note that since defining a System namespace will cause all kinds of trouble, I use Core as my "system/global" namespace.

这篇关于我应该担心卫冕的命名空间数/长度/范围有多大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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