Out of last installment of my .NET Architecture class I got a post-class question about what goes in the view and what shouldn’t. The question related to using the MVP pattern in a Web Forms scenario, but I’m more or less facing the same doubts myself in the context of an ASP.NET MVC project. So in general the question can be rephrased and generalized like below:
How smart do you want your view class to be? In ASP.NET MVC, it is about how much Razor code you want to have in the CSHTML file. In Web Forms with MVP, it is about how much logic you want to have in the class that implements the view interface.
The amount of logic in the view is a scenario that brought some people to split the MVP pattern in Passive View and Supervising Controller patterns. Essentially, MVP leaves up to you the choice of how much logic you want in the physical view (ie., the ASPX). So according to Martin Fowler, Passive View is the logic-less view (just humble and passive) and the other is the view with some logic such as validation or ad hoc formatting.
Both options are equally good from a design perspective. Personally, I would opt for a view-specific solution for simple things like required, numeric, range, reg-exp. In a web scenario you can find “native” solution through server controls or data annotations or jquery validation. For more sophisticated things, I’d move it up to the presenter so that the presenter gets raw data from the view and filters/validates that for callers.
But this is just my rule of thumb.