- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当杰里米和查德 posted about their FubuMvc project ,他们提到的差异化因素之一是他们的“雷霆穹顶校长”:
The “Thunderdome Principle” – All Controller methods take in one ViewModel object (or zero objects in some cases) and return a single ViewModel object (one object enters, one object leaves). The Controller classes will NEVER be directly exposed to anything related to HttpContext. Nothing makes me cry like seeing people trying to write tests that mock or stub that new IHttpContextWrapper interface. Likewise, Controller methods do not return ViewResult objects and are generally decoupled from all MVC infrastructure. We adopted this strategy very early on as a way to make Controller testing simpler mechanically. It’s definitely achieved that goal, but it’s also made the Controller code very streamlined and easy to read. We’ll explain how this works at KaizenConf.
他们的“一个 ViewModel(或零个)”方法的优势是什么?
最佳答案
它的主要好处是它是一种约定,并使我们所有 Controller 之间的事情保持一致。它使我们更容易设置可以在集成测试场景中初始化环境的测试“上下文”/装置。在大多数情况下,约定==快速,因为它从您的设计考虑中消除了许多“假设”场景。
由于我们所有的 Controller 操作都遵循相同的模式,因此我们可以假设很多事情,它加速并简化了我们的 Controller 集成测试工作。
为 Controller 操作提供多个参数必然没有什么问题,但我们发现拥有一个实际的模型对象为我们提供了一些额外的功能,因为模型可以包含简单的逻辑并公开便利的属性,这些属性可以简单地实现一些功能其自身状态的复杂方面等——基本上,这是拥有任何丰富模型的论点,并且不是 Thunderdome/OMIOMO 模式所独有的。
关于asp.net-mvc - Thunderdome MVC - 为什么在 MVC 中使用一个模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/518325/
当杰里米和查德 posted about their FubuMvc project ,他们提到的差异化因素之一是他们的“雷霆穹顶校长”: The “Thunderdome Principle” –
我知道 Thunderdome 原理的基本概念(一个对象进入,一个对象离开),但我在 asp.net mvc 中没有看到任何真实世界的示例。 是雷电原理的好例子吗 public ActionRes
我是一名优秀的程序员,十分优秀!