Should the folders in a solution match the namespace?(解决方案中的文件夹是否应该与命名空间匹配?)
问题描述
解决方案中的文件夹是否应与命名空间匹配?
Should the folders in a solution match the namespace?
在我的一个团队项目中,我们有一个类库,项目中有许多子文件夹.
In one of my teams projects, we have a class library that has many sub-folders in the project.
项目名称和命名空间:MyCompany.Project.Section.
Project Name and Namespace: MyCompany.Project.Section.
在这个项目中,有几个文件夹与命名空间部分匹配:
Within this project, there are several folders that match the namespace section:
- 文件夹 
Vehicles在MyCompany.Project.Section.Vehicles命名空间中有类 - 文件夹 
Clothing在MyCompany.Project.Section.Clothing命名空间中有类 - 等等
 
- Folder 
Vehicleshas classes in theMyCompany.Project.Section.Vehiclesnamespace - Folder 
Clothinghas classes in theMyCompany.Project.Section.Clothingnamespace - etc.
 
在同一个项目中,还有另一个恶意文件夹
Inside this same project, is another rogue folder
- 文件夹 
BusinessObjects在MyCompany.Project.Section命名空间中有类 
- Folder 
BusinessObjectshas classes in theMyCompany.Project.Sectionnamespace 
有一些类似的情况是为了组织方便"而制作文件夹.
There are a few cases like this where folders are made for "organizational convenience".
我的问题是:标准是什么?在类库中,文件夹通常与命名空间结构匹配还是混合包?
My question is: What's the standard? In class libraries do the folders usually match the namespace structure or is it a mixed bag?
推荐答案
另外,请注意,如果您使用内置模板将类添加到文件夹,默认情况下会将其放在反映文件夹层次结构的命名空间中.
Also, note that if you use the built-in templates to add classes to a folder, it will by default be put in a namespace that reflects the folder hierarchy.
课程会更容易找到,仅此一项就足够了.
The classes will be easier to find and that alone should be reasons good enough.
我们遵循的规则是:
- 项目/程序集名称与根命名空间相同,除了 .dll 结尾
 - 上述规则的唯一例外是项目以 .Core 结尾,.Core 被剥离
 - 文件夹等于命名空间
 - 每个文件一种类型(类、结构、枚举、委托等)可以轻松找到正确的文件
 
这篇关于解决方案中的文件夹是否应该与命名空间匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:解决方案中的文件夹是否应该与命名空间匹配?
				
        
 
            
        基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
 - 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
 - 如何动态获取文本框中datagridview列的总和 2022-01-01
 - 错误“此流不支持搜索操作"在 C# 中 2022-01-01
 - 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
 - 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
 - 首先创建代码,多对多,关联表中的附加字段 2022-01-01
 - 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
 - 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
 - JSON.NET 中基于属性的类型解析 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				