There, I've said it. If Castle Project has been on your "need to check that out list," you very much need to make it a higher priority. Recently, I discussed how our development team has been migrating a 1 1/2 year old project into the MonoRail framework. We had been using Windsor for some time but needed a simpler approach to managing the separation of presentation and logic. MVP was our previous approach which we were implementing in a disciplined manner, exactly as I described in a previous article; but after a year or so of using it, we began finding MVP becoming cumbersome, not worth the effort on simpler pages, and tricky to determine exactly where the line is to be drawn between the code-behind and the presenter. (This becomes particularly difficult when taking a Supervising Controller approach as opposed to a Passive View approach as the view may still have access to the domain. But I still prefer it over Passive View as it decreases the amount of primitives and DTOs being passed between the view and the presenter.) The only real drawback to integrating Castle Project tools with legacy code is that it is difficult to appreciate all that the Castle Project has to offer.
Over the past couple of weeks, I've been fortunate enough to do a small ecommerce website from the ground up with everything Castle Project has to offer. What I've found particularly pleasing is that it just works. I needed to add ajax support to a "contact us" page to replace the input form with a thank you message; with just a couple of lines of code, AjaxHelper made it trivially simple. (IMO, only telerik rivals Castle's simplicity with respect to AJAX.) I needed to get my code talking to a database; ActiveRecord required about 10 minutes to set up my entire data communications layer...no DAOs to manage, no NHibernate HBMs to create, and certainly no SQL to write. (I doubt that I would use ActiveRecord on a large project in favor of a cleaner separation of domain and data, but for smaller projects, it's perfect.)
But what I believe to be the real gem of Castle Project is the MonoRail MVC framework. MonoRail enforces a very clean separation of presentation and logic while still allowing the view to access domain properties when using the Brail view engine (e.g., someUser.FullName); similarly to what Supervising Controller provides but without the gray area of separation. MonoRail also fully supports TDD development of both the views and controllers which was my former motivation behind using the more complicated architecture, MVP. Furthermore, MonoRail abandons the ASP.NET page lifecycle events...I never realized how much headache the page lifecycle caused until I didn't have to deal with it anymore. Everything is just HTML and JavaScript with a pure and simple HTTP request and response. If you use the SmartDispatcherController with the DataBindAttribute - and I don't know why you wouldn't - the data binding between the form and the controller is seemless and strongly typed. Yes, you can do comparable feats with ObjectDataSources in ASP.NET, but, IMO, it's much simpler in MonoRail while still providing a very clean separation between presenation and logic.
A major concern I had about moving to MonoRail was the limited support for sophisticated, off-the-shelf, ASP.NET user controls such as what telerik has to offer. I've come to find that:
-
You generally don't need the complicated sophistication that third party tools tout. Most of the time, these features are gold-plating that clients never use which are only offered to make the lives of developers more interesting. (I put myself squarely in that camp.) Take grids for example. Off-the-shelf, third party grids typically provide features such as drag-and-drop dynamic grouping, drag-and-drop column ordering, column resizing, and keyboard navigation. These features are a lot of fun, but they're almost always gold-plating. In the 10 years I've been developing, I've never had a client request one of these features...it's not because they're (all) ignorant, it's because they just don't need it. When you consider that 2/3 of projects significantly overrun their cost estimates and that 64% of features included in products are rarely if ever used [
Agile Estimating and Planning by Mike Cohn], do we really need to be pushing all these gold-plated bells and whistles? Furthermore, I can't tell you how many hours I've wasted trying to customize one of these features to "do what I want it to do" when it never really needed to be there in the first place.
-
Alternatives exist to give you the same time savings that off-the-shelf .NET controls provide. In addition to
helpers provided within MonoRail, many other options are available for developing sophisticated web applications. The
Yahoo! User Interface Library provides animation utilities, drag and drop capabilities, pop-up calendars, rich text editors, menus, trees, and a rapidly improving data grid.
Script.acul.us provides a potpourri of visual effects rivaling what can be done in WPF. Here's a few more to help extend your coding reach:
prototype,
dojo,
dojo offline, and
Google Gears.
-
MonoRail view components are much simpler than ASP.NET user controls. No page lifecycle, no weird binding problems...just basic HTML, JavaScript and a simple HTTP request and response. The increased simplicity means faster development and less painful maintainance. It also means less time pounding the desk trying to figure out why the Page_Load of one control didn't set the proper values in the selection box because someone called Page.DataBind() in some other control. Of course you'll still find yourself stuck on challenges, but you'll have less moments yelling at the code, "what's wrong with, you should be working just fine!" Over the past week, I've found myself with a big grin time and time again after writing some code and seeing it work exactly as I had expected it would. It just works.
As I'm starting to sound like a used car salesman, I believe I should stop while I'm ahead (or at least at an even keel). The bottom line is that Castle Project really does provide an all in one package for improving the web development experience...definitely cooler than Jerry Springer.
Billy McCafferty
Posted
09-21-2007 9:58 AM
by
Billy McCafferty