C# 解决方案 - 有多少个项目?
我用谷歌搜索了一下,但找不到好的结果。
现在我正在构建一个网站,我从一开始就试图从设计的角度使其尽可能正确。
我现在面临的问题是,当决定开始日志记录时,我需要一个项目来放置此代码。由于我在当前项目中找不到合适的位置,我想:嘿,为什么不使用日志记录类库呢?
是否有关于您应该拥有多少项目的一般准则?我知道这将是一个相当小的项目,但如果能完全摆脱它,那就太好了!
任何提示表示赞赏:)
I googled this a little but couldn't find a good result.
Right now I'm building a web site and I'm trying to make it as correct as possible from a design point of view from the beginning.
The problem I'm now facing is that when deciding to start with logging I needed a project to place this code in. As I could not find a suitable place in my currect projects I thought: hey, why not a logging class library?
Is there a general guideline on how many projects you should have? I know this would be a rather small project but it would be nice to entirely get it out of my way!
Any hints are appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
你绝对应该有一个日志库。如果您要使其“从设计角度尽可能正确”并且您的项目不是微不足道的,那么您绝对应该拥有一定数量的项目。问题是,除了它是一个网络应用程序之外,我们不知道您在做什么。商业领域通常决定了您的解决方案的复杂程度。
Absolutely you should have a logging library. And if you're going to make this as 'correct as possible from a design point of view' and your proect is less than trivial then you should definitely have some number of projects. The thing is, we have no idea what you're working on besides the fact that it's a web app. It's the biz domain that often determines how complex your solution has to be.
我会为一个小项目选择三层架构。
这将包括:
但如果您想添加日志记录,最好创建另一个项目。这也会对您有所帮助,因此如果您想将日志记录添加到另一个应用程序,您只需包含日志记录项目即可。
I'd go for a three-tier architecture for a small project.
This would include:
but if you want to add logging, it would be best to create another project. This would also help you so that if you want to add logging to another application, you can just include the logging project.
如果您担心解决方案中的项目限制,则任何一种方法都可以。别这样。
我自己会把它放在一个单独的项目或一个实用项目中。
Either way would work, if you are concerned about project limit in a solutions. Don't be.
I myself would put it in a separate project or a utility project.
我们拥有包含 200 多个项目的解决方案。缺点是 Visual Studio 中的加载时间较长。但除此之外,唯一的问题是确保你有足够的内存。
此外,MSBuild.exe 已构建-支持 SLN 文件,因此如果您正在进行自动化构建,请考虑使用它而不是 Visual Studio。
We have a solution with 200+ projects. The downside is long load time in Visual Studio. But past that the only issue is making sure you have enough RAM.
Also, MSBuild.exe has built-in support for SLN files, so look into using that instead of Visual Studio if you are doing automated builds.
“一起更改的内容应该打包在一起”,我忘记了该指南的来源(也许是代码完整?)。
换句话说,您的程序集(项目)应该以与较低级别的类/对象相同的方式表示连贯的抽象。
所以,是的,一个单独的日志记录项目是正确的选择(尽管在您推出自己的日志记录块之前,请先检查一下 log4net 或 Microsoft 的日志记录块!)
"That which changes together should be packaged together", I forget where that guideline comes from (Code Complete maybe?).
In other words your assemblies (projects) should represent a coherent abstraction in the same way your classes/objects do at a lower level.
So yes, a separate logging project is the right way to go (although do check out log4net or Microsoft's logging block before you roll your own!)
将日志记录到一个单独的项目中是完全可以的。但是,这实际上取决于您项目的范围。我通常像这样设置我的项目
YourProject.Web(web 项目)
YourProject.Core(所有业务逻辑)
YourProject.Web.Tests (Watin 测试)
YourProject.Web.Core.UnitTests(单元测试)
YourProject.Web.Core.IntegrationTests(集成测试)
我建议您从 asp.net 查看项目的组织方式。
Put a logging into a separate project is perfectly fine.However it really depends on the scope of your project.I normally setup my project like this
YourProject.Web(web project)
YourProject.Core(all the business logic)
YourProject.Web.Tests(Watin tests)
YourProject.Web.Core.UnitTests(Unit tests)
YourProject.Web.Core.IntegrationTests(Integration tests)
I suggest you to download some open source Project from asp.net to see how the project have been organized.