Thunderdome MVC- Why one model in MVC?

When Jeremy and Chad published their FubuMvc project , one of the differences they talked about was their Thunderdome Principle:

"Thunder Rain Principle" - All Controller Methods take one ViewModel (or zero objects in some cases) and return one ViewModel (one object enters, one object leaves). Controller classes will NEVER be directly affected by anything related to the HttpContext. Nothing makes me cry, like seeing people trying to write tests that mock or drown out that new IHttpContextWrapper interface. Similarly, controller methods do not return ViewResult objects and are typically decoupled from the entire MVC infrastructure. We adopted this strategy as a way to conduct controller testing mechanically easier. Definitely achieved this goal, but its controller code is also very optimized and easy to read. Explain well how this works at KaizenConf.

What is the advantage of their "single ViewModel (or zero) in the" approach "?

+8
model-view-controller asp.net-mvc controller fubumvc
Feb 05 '09 at 22:44
source share
3 answers

Its main advantage is that this agreement makes everything consistent in all of our controllers. This makes it easy for us to set up testing of “contexts” / devices that can initialize the environment in an integration test script. In most cases, Conventions == Rapidity, since it removes a lot of "what if" scripts for your design reasons.

Since all our actions with the controller follow the same pattern, we can assume many things, and this speeds up and simplifies our integrated efforts to test the controller.

There is nothing wrong, necessarily, having a few arguments for the controller’s action, but we found that the presence of the actual model object gives us additional functionality, since the model can contain simple logic and reveal convenient properties, which may just be some of the more complex aspects of its own state etc. - basically, this is an argument in favor of having any rich model and is not unique to the Thunderdome / OMIOMO template.

+9
Feb 06 '09 at 16:12
source share

The advantage is that you do not rely on any context (for example, session state, for example) from outside the controller methods. This makes testing them easier since you don’t need to “mimic” this context with mocks, but it also makes it less practical as you need to pass everything by parameters.

0
Feb 05 '09 at 23:25
source share

The advantage of the thunderdome principle is that it simplifies the operation of controllers. Since the work of comparing http values ​​with objects is done outside the controllers, this means that the controllers do only what they need.

0
Feb 06 '09 at 4:25
source share



All Articles