可以将代码放在项目的根目录中吗?
我正在尝试提出有关项目目录结构的最佳实践。
我最新的想法是项目的根目录中不应该有任何类。 所有类都必须位于以下目录之一下
- UI
- BusinessObjects
- BusinessLogic
- DataAccess
我想听听其他人的想法是否存在将事物放在根级别或查找不适合的类的用例
I am trying to come up with a best practices on project directory structure.
my latest thought is that there should be no classes in the root directory of a project. All classes must go under one of the following directories
- UI
- BusinessObjects
- BusinessLogic
- DataAccess
i would like to hear other people thought on if there are use cases for putting things at the root level or find classes that wouldn't fit into
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您谈论的是 C#,那么我会将您的 DAL、BLL、GUI 分离到不同的项目而不是一个项目。 并且有一个解决方案。 这将强制每个代码文件位于其中一个项目内。
我添加了一个示例:
如果可能的话,你应该给网站和 winforms 项目一个与你的应用程序相关的名称。
If you're talking about C# then I would separate your DAL, BLL, GUI to different projects instead of one project. And have one solution. This will force each code file to be inside of one of the projects.
I've added an example:
If possible you should give the website and winforms project a name relative to your application.
这个博客应该为您提供一些有趣的读物,尽管已经发布了三年。 除了目录结构之外,它还可能为您提供一些想法。
This blog should provide you with some interesting reading, despite being three years old. It might give you ideas besides those of just directory structure.
我放入根文件夹的唯一文件是 Program.cs 和 Program.ico (如果它是可执行应用程序)。
The only files I put into root folder are Program.cs and Program.ico (if it's executable application).
我不这样做,但它与目录结构无关(对我来说)。 我希望所有代码都位于有意义的命名空间中。
I don't do it, but it has nothing to do with the directory structure (for me). I want all my code in meaningful namespaces.
我总是将项目异常的基类放在根目录中。
I always put the base class for my projects exceptions in the root.