View artifacts leaking into the model of MVC

Posted by Jono on Stack Overflow See other posts from Stack Overflow or by Jono
Published on 2010-05-08T09:47:16Z Indexed on 2010/05/08 9:58 UTC
Read the original article Hit count: 251

Filed under:
|
|

In an ASP.NET MVC application (which has very little chance of having its view technology ported to something non-HTML, but whose functional requirements evolve weekly,) how much HTML should ideally be allowed to be directly represented in the Model?

I might come across as a design bigot for this, but I regard it as bad practice to allow any view constructs to "leak" into the model in an MVC application (and vice versa). For example, a Model that represents an item you're about to purchase should know nothing about the HTML check box that says "add giftwrap/message", nor should it know about any HTML drop down lists for payment card types. Conversely the View shouldn't be doing work like figuring out button text by translating keys into values (by looking in resource files.)

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about mvc