MVC Preview 3 Released

MVC Preview 3 has been released this week and Scott Hanselman has already released a video. If you have not yet played with MVC, it is starting to shape up. You can download the code from Phil Haack’s blog site.

In the past, I have been a bit critical of MVC. It is not that I do not like MVC, or I feel it is not up to snuff, etc. My main issue has been that while it is testable, and does separate concerns, it also couples the view with the data rather strongly. Let me show you what I mean with a few samples.

First, here is a link:

<%= Html.ActionLink("Linktext 123", "OrderDetails", "Orders") %>

Now, this is not really all that bad, as I can easily alter the code. But, if I end up renaming something in a controller (which I shouldn’t do too much if I planned before I built), I end up with a lot of editing in my views, especially, if I have plenty of links.

Next, let’s bind some data:

<h2><%=ViewData.CategoryName %></h2>


    <% foreach (Product product in ViewData.Model.Products.Model) { %>

        <li id="prod<%= product.ProductID %>">
            <%= product.ProductName %>
            <span class="editlink"">
                (<%= Html.ActionLink("Edit", new { Action="Edit", ID=product.ProductID })%>)

    <% } %>


I am not snitting a big deal about this, but it looks an awful lot like traditional ASP. I have completely migrated away from the ASP.NET binding model, where I place a control and bind it to a data source (sometimes with no additional information) and I am now looping again. Yes, I know I was always looping in the Microsoft code anyway (easily confirmed by adding code into the row binding events), but this just feels a bit backwards.

Once again, I am not going to avoid MVC over this, but I am ending up with GUI goodness that cannot easily be tested (in the unit test sense). I do get the benefit of separation of concerns, of course, but I was putting most of my code into libraries anyway (my primary reasoning is I can throw any GUI on top of my app that way).

To be perfectly honest, I am not sure how I would solve this. How do I make MVC views where I can drop controls and bind them rather than loop? How do I get back to an easy to develop experience? There has to be some way. I will venture a guess that it will not be solved prior to final release, however.

Please note I am not against MVC. I think one of its strongest "artifacts" is the fact it forces the separation of concerns. In its first iteration, however, I am fearful it will be difficult enough to use that those who need the "lesson" will not venture into the classroom. I pray I am wrong with this, as I would like to see more developers "get this".

Tomorrow, maybe I will rant on why many advanced developers suck? Sorry, just a bit tired of dealing with applications that have advanced features but miss the basics. If I do, I will also be shooting at myself, as I am still learning not to suck so bad. ;->

Peace and Grace,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: