Jeremy D. Miller -- The Shade Tree Developer

Sponsors

The Lounge

Syndication

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
The best (and next best) possible advice I could give you about using the MVC framework

I ditched quite a bit of some complicated server side state management / screen workflow around the MVC framework today in favor of just a little bit of client side code with the jQuery.Form component.  The lesson learned today for me, and not for the first time, is to keep your MVC framework usage and the server side views as simple as possible. Take all that time you saved on fancy server side work and apply it to serious jQuery-fu.  I would have positioned our design so much better upfront if I'd just taken the freakin' jQuery in Action book home over the weekend early on our project instead of doing so many deep dives into the MVC code.

Of course, since we're doing so much more jQuery coding on the client, it's making it more and more important to test the UI in multiple browsers.  I hit one of those cases today where something worked perfectly in Firefox (what I think all of us use day to day) but not in IE.  We already use QUnit quite a bit for unit testing client side Javascript, but it's only running in IE during the CI build.  We also have end to end tests with Watin, but again, that's IE only.  I think we'll make the minor move to write a QUnit/Firefox runner for CI, and I think I'm going to go take a much longer look at Selenium RC which supports multiple browsers for the end to end testing. 



Posted Thu, Sep 11 2008 6:51 PM by Jeremy D. Miller

[Advertisement]

Comments

Ayende Rahien wrote re: The best (and next best) possible advice I could give you about using the MVC framework
on Thu, Sep 11 2008 9:38 PM

Agreed.

Note that Watin also work with FireFox, if you install a Firefox addon.

josh wrote re: The best (and next best) possible advice I could give you about using the MVC framework
on Thu, Sep 11 2008 10:41 PM

I'm a big fan of jquery, but have this lingering reservation about trusting client side script too much.  Do you forsee any vulnerability to attack or data-integrity in using jquery for forms this way?

Julian Jelfs wrote re: The best (and next best) possible advice I could give you about using the MVC framework
on Fri, Sep 12 2008 3:47 AM

Sounds like we have gone down a very similar route. We are generating client side views composed from individual js components. This is all generated off the server side view (ascx). I found that QUnit was lacking in its support for asynchronous scenarios of which there are many (particularly if you start using visual effects). In the end I wrote my own which is very similar but allows you to specify how many assertions the test expects and doesn't evaluate whether it has passed or failed until it receives those assertions. This enables you to support longer running tests without a problem. We drive our js tests by having WatiN run them from an nUnit test (which allows us to plug into CI).

This style of development raises a big question that I've never had answered. How do you deal with the client-server divide when trying to do MVC in the web scenario? Do you have a client view, client controller as well as a server view and server controller? Thet's kind of what we do.

Gøran wrote re: The best (and next best) possible advice I could give you about using the MVC framework
on Fri, Sep 12 2008 5:02 AM

Hi Jeremy!

I used QUnit to test a few jQuery plugins I wrote, and the developer experience was good enough. Let us know if you're thinking about to release the bits for the QUnit test runner!

I totally agree with you on keeping the server side views as simple as possible. I also use lots of jQuery-fu (as you call it) in the view. That's why I've developed a few jQuery plugins for MVC to ease the gluing part between the view and the controller on the server side. It can easily be modified to support other MVC based web frameworks as Struts, RoR or monorails. You can read more about it here: blog.goeran.no/PermaLink,guid,e55bfb55-ac10-48db-98a4-d28343e0f98a.aspx

Feel free to use the code as you like! I would be very happy if you find it helpful and you can use it in your project.

Keep up the good work!

Cheers

Gøran

Boguslaw Faja wrote re: The best (and next best) possible advice I could give you about using the MVC framework
on Fri, Sep 12 2008 5:05 AM

Selenium supports firefox too. I use it, and it's amazing tool. For me, the best one.

Paul Batum wrote re: The best (and next best) possible advice I could give you about using the MVC framework
on Fri, Sep 12 2008 5:57 AM

Any chance of a follow up post on this Jeremy? I'd love to see an example the server side version vs the jquery version.

Dew Drop - September 12, 2008 | Alvin Ashcraft's Morning Dew wrote Dew Drop - September 12, 2008 | Alvin Ashcraft's Morning Dew
on Fri, Sep 12 2008 9:44 AM

Pingback from  Dew Drop - September 12, 2008 | Alvin Ashcraft's Morning Dew

Ricky Rosario wrote re: The best (and next best) possible advice I could give you about using the MVC framework
on Sun, Sep 14 2008 1:20 AM

I agree that jQuery/JavaScript can make things easier, but I think you need to get all the core functionality to work first before introducing a single line of JavaScript. Progressive enhancement!

Jeremy D. Miller wrote re: The best (and next best) possible advice I could give you about using the MVC framework
on Sun, Sep 14 2008 11:46 AM

@Ricky,

Part of the point of this post is that some of the CORE functionality has turned out to be easier and cleaner to implement with jQuery that it would be with server side state management.  I'm not talking about flashy/glowy stuff here, I'm talking about data entry mechanics.

DotNetKicks.com wrote The best (and next best) advice I could give about using ASP.NET MVC
on Wed, Sep 17 2008 11:51 AM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Code Monkey Labs wrote Weekly Web Nuggets #30
on Sun, Feb 22 2009 10:46 PM

General Some IoC Container Guidelines : Jimmy Bogard presents some good guidelines for working with your IoC container of choice. Lambdas – Know Your Closures : Jason Olson exposes a tricky behavior of lambdas that can bite even folks that consider

Add a Comment

(required)  
(optional)
(required)  
Remember Me?