MVC领域的企业 - 好还是坏? [英] MVC Areas for enterprise - good or bad?

查看:168
本文介绍了MVC领域的企业 - 好还是坏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个单独的项目解决方案引入领域,当你有很多的控制器确实提高了分离,允许模块能够轻松地或出液被复制。不过,在大型企业解决方案我赞成分裂的逻辑放到单独的项目来代替。

Within a single project solution introducing Areas when you have a lot of controllers does improve separation and allows modules to easily be copied in or out of the solution. However in a large enterprise solution I would favour splitting the logic into separate projects instead.

因此​​,有独立的UI,控制器,SOA,模型和信息库项目。在这种情况下区域没有意义更多,再加上他们添加额外的顶层这往往是没有必要的网址,但我相信你可以省略的区域在URL中,如果你保持你的控制器独特的,而不是这有点臭?

Thus having separate UI, Controller, SOA, Model and Repository projects. In this scenario Areas don't make sense any more, plus they add an extra top level to the Url which is often not needed, although I believe you can omit the area in the Url if you keep your controllers unique, but isn't that a bit smelly?

也许领域有利于中等复杂的网站或模块时,code为更好地保存在一个位置,因此它可以被复制到其他站点或删除。

Perhaps Areas are good for medium complexity sites or when module code is better kept in one location so it can be copied to other sites or removed.

推荐答案

我不知道如果这是正确的问题。区域可以矫枉过正的小项目,但很难想象一个非不使用的区域,以帮助保持类-trivially大型项目组织的。

I'm not sure if that's the right question. Areas can be overkill for small projects, but it's hard to imagine a non-trivially large project not using areas to help keep classes organized.

我使用MVC领域,为企业和喜爱它几件事情


  1. ,通常人们在给定域中工作的功能(例如,搜索,结帐等)。如果该区域的名称与您的业务领域相对应, MVC领域有助于减少需要实现的功能的时候,因为相关的类很容易找到。

  2. MVC路由使您能够怎么怎么的URL结构一吨的灵活性。我以前使用Action控制器模式但对于非面向公众的网址,我刚才完全接受的区域默认路由让一切变得简单。

  3. 领域给你造型的独特优势,更重要的是,封装的行为在一个站点科级。每个区域都有自己的网络配置,你可以控制基本视图页面或添加管理处理程序。

  1. Typically people are working on a feature within a given domain (e.g., Search, Checkout, etc). If the area names correspond with your business domains, MVC Areas help reduce the time it takes to implement a feature, because the related classes are easy to find.
  2. MVC routing gives you a ton of flexibility over how how structure the URLs. I used to use the Action Controller "pattern" but for non-public facing URLs I've just fully embraced the Area default route to make things easy.
  3. Areas give you the distinct advantage of styling and, more importantly, encapsulating behavior at a site-section level. Each area gets its own web config where you can control the base view page or add managed handlers.

你是绝对正确的服务应该是在单独的项目/解决方案完全,抽象通过仓库的数据访问,在多个客户端可以访问常用商务功能的环境。

You're absolutely right that services should be in separate projects / solutions altogether, that abstract the data access via repositories, in an environment where multiple clients can access common business functionality.

但MVC领域处于提供了一些为了在UI /路由乱作为web项目的发展,这对我来说,是非常宝贵的,不管背景大。

But MVC Areas are great at providing some order to the UI / routing chaos as a web project grows, which, to me, is invaluable, regardless of context.

这篇关于MVC领域的企业 - 好还是坏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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