clientscript as the view controller

I’m finalizing my demos for next week’s talk at the Tampa ASP.NET MVC user group. I’m also in the midst of a deploy to our test servers of among other things a page that is an experimental architecture for me and my team. I was talking with my boss (Perry for those of you who attend Tampa UX). He had to do a little touch up on my quickly thrown together UI. He told me after playing with it that he really liked how it performs and even how it works. He thinks it’s a pretty good UX.

It’s actually very similar to DT Mini Mint (the app I’ll show at Tampa ASP.NET MVC user group next week).

The idea behind it is that the initial page is pushed out by the server and then additional data is retrieved on the fly via services (or JSON views in MVC) using JavaScript; additional functions like updates, deletes, adds, and more complex operations use the same mechanism.. so the page never refreshes once it has been rendered the first time (no, I’m not using any kind of partial view in any of my examples.. not that I couldn’t, but I don’t have that much to render in either app).

I jokingly referred to “Jay’s Dream Architecture” on Twitter, but was never really able to fully quantify what I was talking about. I likened it to MVC where the model was the service, and the controller was the JavaScript code..

After Christopher Bennage came to Tampa UX last month, we came up with a term (that I’m sure already existed): JavaScript View Controller (or JC). I loved annoying Christopher by saying I was going to attribute the MVCJC pattern to him (it seems he really loves the over use of letters in Pattern names <smile />). So remember he came up with the name for this pattern…

I’m finding more and more that I am building key pages (not all pages) that have everything they need to get started but then user interactions that would normally cause a Postback or a Ajax Postback (for an UpdatePanel), etc. I’m replacing with a client-side Ajax call to a service (for WebForms) or a client-side Ajax call to a controller action (for ASP.NET MVC). The end result is a fairly responsive UI that gives me options.

Back to my discussion with my boss today.. One of the things we realized is that side effect of this is there is an occasion where I have in memory the all the data in memory for render a client side paged grid (we’re talking at most 1000 rows of data… more like no more than 700 rows.. probably much smaller than that). We realized with this architecture and the rows in memory we could easily let the user filter the results client-side via textbox that updates the grid after filtering by the value in the test box.. without any hops back to the server)..

A similar thing for my ASP.NET MVC talk in 2 weeks is that I’m going to be replacing a standard select with an autocomplete text box that uses the original select’s options array as the source for the autocomplete suggestions text (you’ll be able to type something new and that new item will be dynamically added to the DB on save). The idea is that the client browser has pieces of data already and doesn’t need to retrieve it. There are also Jquery cache plugins that can help with this (something I won’t be showing)..

Bottom line is that the client is a for real place where we can write code and make the user’s experience better (I know I’ve not been one to totally go gaga in this arena in the past, but I’m starting to warm to it.. I think Jquery is the big reason why, too.. it’s very mature and really makes it easy to write complex interactions without writing tons of code..)

Print | posted on Monday, June 01, 2009 2:34 PM


# re: clientscript as the view controller

left by Kyle Baley at 6/1/2009 8:20 PM Gravatar
We've settled on a similar architecture whereby the "view" is basically static HTML that retrieves everything via service calls. When we decided on it, we realized that we didn't actually *need* ASP.NET MVC so we're test-driving OpenRasta, which seems to support content-type negotiation a lot better. Will be interesting to see how things shape up in this area in the coming months/years.

# re: clientscript as the view controller

left by Bryan Batchelder at 6/2/2009 12:11 PM Gravatar
I've done the same thing recently for an app that heavily uses Virtual Earth - where you simply cannot postback.

I actually ended up using a mix of ASP.NET Ajax UpdatePanels, Jquery calling ScriptMethods returning JSON, and Jquery calling generic handlers (.ashx) that would instantiate a user control, pass in any required parameters, render it to HTML, and pass back the html to be inserted somewhere in the page (so called AJAH).

I live in Wesley Chapel...been meaning to drop into one of the Tampa UX meetings...
Comments have been closed on this topic.