Controller bloat?


Some of my background information first:

  • 2 years classic ASP (ASP 3.0)
  • 5 years ASP.NET
  • 1-2 months MonoRail
  • 10 minutes ASP.NET MVC
  • ~45 seconds Ruby on Rails

That’s the sum of my experience with different web application frameworks.  Obviously it’s weighted towards ASP.NET WebForms.  Having completed a project with MonoRail and looking at ASP.NET MVC, I can’t help but feel that the Controller and the accompanying Context objects seem bloated.

Now, I’ve already shown I’m no MVC expert, not even close.  But this seems a little bloated for something that’s supposed to be lightweight:

Sorry about the size, but it’s nice to see it in all its glory.  That’s the MonoRail Controller and RailsEngineContext (the HttpContext-like object of MonoRail).  Controller depends quite a bit on the IRailsEngineContext, so you can’t really do much with a Controller in a unit test without mocking out the entire IRailsEngineContext and all of its properties (IResponse, IRequest, etc.).

Here’s the ASP.NET MVC Controller and Context from the Preview 2 drop:

The Controller is smaller, but the Context is larger.  Again, the Controller makes heavy use of the HttpContextBase (formerly IHttpContext), as shown in Scott Hanselman’s recent podcasts.

Having next to zero experience with other MVC frameworks like Rails or Merb, I’m really curious to see how lightweight their controllers are.  I’m not sure lightweight controllers matters, or if the idea of a POCO controller would do anything.  Since we have to inherit from a Controller base class, we’re saddled with its weight.

I’ll repeat again: I’m not an MVC expert.  But these controllers seem bloated to me and their accompanying Context objects seem bloated, as if I need to give the controller the IKitchenSink to get it to work under test.  Does anyone else get this feeling too?

Mapping options in LINQ to SQL