SonicCast #3 - It is not MVC

time to read 3 min | 449 words

I have finished watching SonicCast #3 - All About MVC, the premise of the webcast is to show MVC pattern in SubSonic.  I don't think that this is what is happening there.

Now, for fair disclosure, I am not a SubSonic user, and I am an active member of the "competing* " projects, Active Record & MonoRail. I thought about not posting this, because of the inevitable flames that criticizing another project will bring, but I think that the subject is important. 

* Competing is not how I see it, parallel project would be a closer way to describe it.

The main problem that I have with the style of coding shown in the webcast is that is it certainly not MVC.

public void Page_Load(object sender, EventArgs e)
	Product p = ProductController.Get(1);

This is not MVC because the control is not in the hands of the controller. In fact, the "controller", in this case, would be more aptly named ProductDAL or ProductRepository. It has no business logic associated with it and it does not take an active part in the processing of the request.

The test that I use for an MVC controller is very simple: "who decide whatever to show the Edit link on the table?" If the decision is made on the code behind, than this is not an MVC. If the decision is made on the controller, than we have proper separation of concerns. And when I am talking about a decision, it can be as simple as setting a flag per record, or the like.

There is nothing wrong with the approach shown, and I have built a large scale system with this approach, but it is not MVC. Testability and therefor, maintainability, of such systems are much harder, since the business logic reside in code that is only accessible by invoking the entire ASP.Net pipeline, but that is another matter.

Toward the end, Rob says:

So while this is still a bit of a data broker pattern, it is as close to the controller pattern as we can get, again because we are bound a little bit by WebForms

So I think that we are in agreement about that, with the difference being in that I don't see this as "a bit of a data broker pattern", I see it as the whole data broker pattern.

Toward the end, Rob mentions that you can map button clicks and other events into the controller, and while it is possible to do it, it is quite a bit of work. And that doesn't give me anything that I can't do manually.

And just to state it again, true MVC is not possible with WebForms