命名空间、文件夹和冗余,天哪!文件夹结构是否清晰?
是的,我查看了一些现有的帖子 将项目文件分组为文件夹/命名空间
c# 解决方案中的命名空间和文件夹结构:磁盘上的文件夹应如何组织?
等。我遇到了一种情况......有点,我不确定我的程序是否过于复杂。
我有三个项目,组织方式很像这样......
Web
- 区域
- 控制器
- 容器
- 模块
- 内容
- CSS
- 脚本
- 图片
- 观看次数
模型
- [Namespace.a] // 示例,Project.Membership
- 消息[查询接口]
- 型号
- 域模型.cs
- 域模型.cs
- 域模型.cs
- 扩展
- 域模型扩展.cs
- 域模型扩展.cs
- 错误
- 域模型错误消息.cs
- 域模型错误消息.cs
- 工厂
- 域模型工厂.cs
- 域模型工厂.cs
- [Namespace.b] // 示例,Project.Books
- 消息[查询接口]
- 型号
- 域模型.cs
- 域模型.cs
- 域模型.cs
- 扩展
- 域模型扩展.cs
- 域模型扩展.cs
- 错误
- 域模型错误消息.cs
- 域模型错误消息.cs
- 工厂
- 域模型工厂.cs
- 域模型工厂.cs
- [Namespace.c] // 示例,Project.Tags
- 消息[查询接口]
- 型号
- 域模型.cs
- 域模型.cs
- 域模型.cs
- 扩展
- 域模型扩展.cs
- 域模型扩展.cs
- 错误
- 域模型错误消息.cs
- 域模型错误消息.cs
- 工厂
- 域模型工厂.cs
- 域模型工厂.cs
- [Namespace.d] // 示例,Project.Blogs
- 消息[查询接口]
- 型号
- 域模型.cs
- 域模型.cs
- 域模型.cs
- 扩展
- 域模型扩展.cs
- 域模型扩展.cs
- 错误
- 域模型错误消息.cs
- 域模型错误消息.cs
- 工厂
- 域模型工厂.cs
- 域模型工厂.cs
- [Namespace.a] // 示例,Project.Membership
你明白了...基本上这个结构对我来说效果很好。我的问题是是否有其他人这样组织,或者我是否只是通过这么多的微型文件夹使我的解决方案加载速度变慢。我的思考过程基本上是..
每个命名空间就像一个文件夹,所以给它一个文件夹。 每个对象就像一个文件,所以给它一个文件夹。 与对象相关的每个事物都像一个属性,因此请组织它们。
一般来说,这听起来像是一个非常愚蠢的问题。我对管理和组织有很强的强迫症,但我想知道是否让一切都保持......模块化这个词是什么?在这种情况下是最明智的决定。目前,我的一个项目中有 28 个命名空间,每个命名空间中包含 3 到 8 个对象。
Yeah, I've looked around at some of the existing posts Grouping of project files into folders/namespaces
Namespaces and folder structures in c# solutions: how should folders on disk be organised?
And the like. I'm running into a situation.. sort of, where I'm unsure if I am over complicating my program.
I have three projects, organized much like this ...
Web
- Areas
- Controllers
- Container
- Modules
- Content
- css
- scripts
- images
- Views
Models
- [Namespace.a] // example, Project.Membership
- Messages [Interfaces for Queries]
- Models
- domain-model.cs
- domain-model.cs
- domain-model.cs
- Extensions
- domain-model-extensions.cs
- domain-model-extensions.cs
- Errors
- domain-model-error-messages.cs
- domain-model-error-messages.cs
- Factories
- domain-model-factory.cs
- domain-model-factory.cs
- [Namespace.b] // example, Project.Books
- Messages [Interfaces for Queries]
- Models
- domain-model.cs
- domain-model.cs
- domain-model.cs
- Extensions
- domain-model-extensions.cs
- domain-model-extensions.cs
- Errors
- domain-model-error-messages.cs
- domain-model-error-messages.cs
- Factories
- domain-model-factory.cs
- domain-model-factory.cs
- [Namespace.c] // example, Project.Tags
- Messages [Interfaces for Queries]
- Models
- domain-model.cs
- domain-model.cs
- domain-model.cs
- Extensions
- domain-model-extensions.cs
- domain-model-extensions.cs
- Errors
- domain-model-error-messages.cs
- domain-model-error-messages.cs
- Factories
- domain-model-factory.cs
- domain-model-factory.cs
- [Namespace.d] // Example, Project.Blogs
- Messages [Interfaces for Queries]
- Models
- domain-model.cs
- domain-model.cs
- domain-model.cs
- Extensions
- domain-model-extensions.cs
- domain-model-extensions.cs
- Errors
- domain-model-error-messages.cs
- domain-model-error-messages.cs
- Factories
- domain-model-factory.cs
- domain-model-factory.cs
- [Namespace.a] // example, Project.Membership
And you get the idea... basically this structure works fine for me. My question is whether anyone else organizes like this, or if I'm just making my solution load slower with this much micro-foldering. My thought process is basically ..
each namespace is like a folder, so give it a folder.
each object is like a file, so give it a folder.
each thing relating to an object is like a property, so organize them.
This may sound like a really stupid question in general. I'm very OCD about management and organization, but I'm wondering if keeping everything so ...what is the word... modular? is the wisest decision in this case. Currently I have 28 namespaces in one of my projects, each with anywhere between 3 to 8 objects in it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我来说看起来很明智。维护布局良好的逻辑文件夹/命名空间层次结构是一种很好的做法。
此外,使用 Resharper 等工具可以非常轻松地快速导航到文件/类型,即使您的文件夹结构确实相当深。
That looks pretty sensible to me. Maintaining a well laid out logical folder/namespace hierarchy is good practice.
Additionally, the use of tools like Resharper make it very easy to quickly navigate to files/types even when you do have a fairly deep folder structure.