在ASP.NET MVC解决方案中是否有定义项目的标准方法? [英] Is there any standard approach for defining projects in an ASP.NET MVC solution?

查看:129
本文介绍了在ASP.NET MVC解决方案中是否有定义项目的标准方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在逻辑上定义ASP.NET MVC解决方案?要分解我的解决方案有多少项目?有没有一个标准的方法呢?例如,模型类库,MVC Web应用程序(包括控制器和视图),单元测试项目,存储库项目等...项目的不同类型可以提出什么?

How should I logically define an ASP.NET MVC solution? Into how many projects must I divide my solution? Is there a standard approach for this? Like for example, a model class library, an MVC web application (comprising controllers & views), a unit test project, a repository project etc... What are the different types of project one can come up with?

推荐答案

答案确实取决于。取决于您的项目的规模。您可以将它全部放在一个项目(主MVC一)中,您可以将其进一步拆分。这个项目的标准形式是这样的:

The answer is really depends. Depends of the scale of your project. You can have it all in one project (main MVC one) of you can split it further. The canonic form for this projects is something like that:

project.WEB
project.Common (here belongs common functionality between projects, so helpers, utilities, even some extension methods belong there)
project.Model (Data entities)
project.BL //(Business Logic)
project.DAL //(Data Access Layer or Persistence)
project.Tests

*请注意项目是您的命名空间根。如何处理命名空间命名,您可以在其中查看:命名空间命名约定

*note the "project" is your namespace root. How ho handle namespace naming you can check it there: namespace naming conventions

您可以进一步分割。但是,我建议你不要夸张地分裂它。当你必须这样做时,你会知道(一个项目增长太多,有逻辑分离...)。您尝试遵循 YAGNI 的原则。

And the you can split it further and further. However I would suggest that you do not exaggerate with splitting it any further. When you will have to do it you will know (one project grow too much, there are logic separations ...). You try to follow the principle YAGNI.

还有一件事。如果你想在那里由书检查出DDD - 域驱动设计: http://msdn.microsoft.com/en-us/magazine/dd419654.aspx

And one more thing. If you want to be there "by the book" check it out DDD - Domain Driven Desing: http://msdn.microsoft.com/en-us/magazine/dd419654.aspx.

这篇关于在ASP.NET MVC解决方案中是否有定义项目的标准方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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