I've now completed my first web application using ASP.NET MVC and overall, I still am not grasping why this is getting all the praise and glory. Maybe I'm being stubborn. I know that what makes MVC great is that is forces separation between the presentation layer and the business object or data layer along with its stateless operation. I also know that when you are working with the view, it appears that the code is less readable (see my example below).
So I guess my question is... If the separation is the concern, why not just separate.
Web Forms View Code:
//UI
<h2><asp:Label ID="lblPageHeader" runat="server" /></h2>
Web Forms Code Behind:
//CODE BEHIND
this.lblPageHeader.Text = myObject.Header;
MVC Code View:
//UI
<h2><%= Html.Encode(Model.PageTitle) %></h2>
MVC Controller Code:
index = new Index
{
PageText = sb.ToString(),
PageTitle = "WELCOME"
};
return View(index);
Again, I might be being stubborn, but one of the things that I really liked in WebForms is the ease in setting object properties like DataSources and Text values. It seems like this is completely different in MVC and less readable which makes me wonder about long term maintenance.
EDIT After looking into the typed models, I think the readability of the code is substantially improved.