Monday, August 3, 2009

TicketDesk 2.0 and the ASP.NET MVC Framework

Now that the ASP.NET MVC Framework is out, I've decided to tackle learning the new platform the same way I usually do... by writing a real application for the new platform.

TicketDesk 1.0 was originally just a playground application to help me get up to speed during the last round of new-tech releases from Microsoft... so it seemed natural to explore the MVC Framework with a re-write of the same application. TicketDesk is just small enough to be workable by a lone part-time programmer, and it is just big enough to provide a decent proving ground for the new technologies.

So let's discuss MVC and how it relates to TicketDesk 2.0...

One of the ironies of my life is that I've been primarily an ASP.NET developer ever since it was first released and I've also been working with MVC and MVC-like development patterns nearly that entire time too.

MVC patterns just makes sense for web apps seeing as the nature of HTTP itself matches that pattern so cleanly. In other environments, MVC has been a formally accepted pattern for years and years.

But ASP.NET Webforms was initially designed to make programming for the web feel more like windows programming with an event driven programming model. Microsoft excels at event driven programming techniques, and the resulting webforms framework was a fantastic adaptation of the pattern into web development space. Webforms allows you to mostly ignore all that messy HTTP stuff and code pages just like you would in a persistent windows environment.

But like most abstractions, webforms tends to break-down when you try to do stuff at the edges. So it wasn't uncommon for platform developers to find problems that just didn't map well to the abstractions provided by webforms. So many of us ended up spending amazing amounts of time hacking into the gap between the webforms model and the raw HTTP pipeline itself.

If you look at the architectures behind most of the larger and more successful ASP.NET application platforms (sharepoint, the 1.x starter kits, IBuySpy, DotNetNuke, CommunityServer, etc.) you will usually find elaborate examples these kinds of hacks. All of them are just variations on a theme... use MVC-like patterns to gain some control over the HTTP request/response pipeline.

With the rise of modern AJAX techniques and technologies, the need for a new approach has become very apparent. Ajax mucks around with the request pipeline in ways that the webforms framework does not tolerate elegantly. If you've tried to do any significant Ajax stuff in webforms, you've probably noticed how quickly things get messy.

Fortunately Microsoft recognized this and decided to formally embrace the MVC pattern. The result is the ASP.NET MVC Framework which was delivered a few months ago.  

Which brings me back to TicketDesk....

I originally built TicketDesk 1.x  as a way to experiment with .NET technologies that were new at the time (Ajax, EF, and LINQ to SQL). So I thought it would be fitting to do the same thing again now to get my hands dirty with the Microsoft MVC Framework.

I didn't port the existing TicketDesk 1.x code though. Instead, I've started with a clean solution and am re-implementing the same set of features as TicketDesk 1.x using all fresh code written for the MVC framework.

I suspected all-along that TicketDesk would probably map very well to the MVC Framework, and I'm no stranger to the MVC design pattern itself. I had also hoped that the MVC design pattern might eliminate many of the obstacles I had encountered especially with the Ajax parts of TicketDesk 1.x.

The experiment is about 3 months old now, and has been very challenging. The MVC Framework itself has a lot of room for improvement, but is a solid foundation on which to start. Some of the most obvious drawbacks are the slim Visual Studio IDE support, sparse documentation, and poor examples of how to do ASP.NET MVC "the right way".

The biggest challenge for me has been the steep learning curve. I've been writing web apps for over 12 years, most of that working with ASP.NET, but the ASP.NET MVC framework really requires an entirely different way of thinking. I'm also just now learning my way around JQuery too which has further slowed me down.

Currently Microsoft is providing only basic Ajax functionality within the MVC framework, but they have encouraged the use of JQuery. JQuery gives you a rich and very successful source for all those fancy UI components that Microsoft doesn't provide on the MVC framework. While the ASP.NET MVC Framework doesn't help you much with JQuery, it also doesn't interfere any.  Future versions of the framework promise to further embrace JQuery head-on. I've not been impressed with Microsoft's own ability to deliver decent Ajax libraries so far, but JQuery has a very large 3rd party community developing high quality code... and most of it is some kind of open source to boot.

While I've found that writing against the MVC Framework takes significantly longer and requires much more effort, the quality and usability of the resulting application is many orders of magnitude better.

So I've formally decided to re-write the official TicketDesk application on the ASP.NET MVC Framework.

The initial 2.0 release will not contain very much new functionality compared to 1.x, but I hope to provide a significantly better user experience and a much more compartmentalized code-base.

Currently TicketDesk 2.0 is targeting the ASP.NET MVC Framework 1.0 on the .NET 3.5 stack. I did experiment with the RTM release of the Entity Framework this time, but I still find that EF is just not ready... so I'll be sticking with LINQ to SQL for a while longer.  I'm confident that I can switch back to EF should the next version resolve my remaining concerns. It is likely that the next version of the MVC Framework will be released before I am done with TicketDesk 2.0, so it will likely shift to target that version before the final release.

Here are some early goals for the TicketDesk 2.0 project:
  • Implement 100% of the functionality from TicketDesk 1.x
      
  • Upgrade Tools for 1.x to 2.x migration
      
  • Improve Application Settings and Administration (more and better online admin tools)
      
  • Improve formatting for RSS and Email notifications
      
  • Enable full functionality for browsers without JavaScript
      
  • Enable smoother Ajax UI features for browsers that do support JavaScript
      
  • Use a Markup editor instead of a WYSIWYG HTML editor (too many problems with raw HTML data entry). I'm currently working with MarkItUp! using Markdown syntax.
      
  • Unit testing for controllers and business/entity logic (using VS Test Project)
      
  • A cleaner separation between the web application and model/business/entity logic
      
  • Fully W3C compliant XHTML 1.0 Strict Output
I have no real time-frame for a 2.0 delivery as this is still a part-time project for me. Currently I have implemented most of the functionality for the TicketCenter, new ticket creation, and have just started work on the Ticket Viewer/Editor.

I have not marked out a potential 1.3 upgrade of the older code-base either, but my primary focus will be on the 2.0 MVC version.


1 comment: