Another approach to ASP.NET MVC categories

Last night I had an idea for a different approach for grouping related controllers into a category that made so much sense, I'm surprised I was able to imagine it.  The idea of actions being grouped into a controller parallels a set of methods being grouped into a class. Taking it a step further, grouping a set of controllers into a category would parallel grouping a set of classes into an assembly.

 

Under this approach, each category would be created as a separate project, referenced back into the main web application.  This has a few advantages over using attributes.  First, it allows real separation, as opposed to the superficial separation that attributes employ.  Second, it's much easier to cache the controllers into categories, as attribute lookups are no longer required, nor is it required to check that category has been added to the cache (as it can be added the moment the assembly is loaded).  It also enforces a design pattern that is much less fragile than attributes (which itself is much less fragile than current implementations I've found), and doesn't feel too restrictive.

 

I plan on keeping both implementations in my framework, as I see they both have advantages over the other.  With many different features being added to my framework, I believe it will be necessary to split it into separate modules.  This will simplify adding needed features, without having to include everything.

Print | posted on Saturday, February 21, 2009 1:07 AM

Comments on this post

No comments posted yet.

Your comment:

 (will show your gravatar)
 
Please add 7 and 3 and type the answer here: