Wednesday, March 21, 2007

Ajax - Do we need a Client Tier (Dave Crane)

Dave started by admitting that he chose the title to provoke a response or trigger interest from the attending people. The answer to his question was Yes by the way.

What he did talk about was the size and importance of the client tier and his conclusion was very straight forward : it depends on how the level of Ajax used. Level seems a strange word to use here but let me put it in perspective. If you use only the UpdatePanels from Ajax for .Net than you are at a very low level but if you are going where no man has gone with Javascript, asynchrosity, and sending or receiving complex structure through XHR (XmlHttpRequest) than you are at a high level.

Dave also mentioned that it is a good idea to set the level at which Ajax is to be used in your design documents or at least bring it up as a design question.

Next on, he explained Java Literals, Closures, and more JavaScript specific stuff in a way that a relatively JavaScript noob like me could understand. I liked the fact that Dave calls Closures akin to inside-out objects. One thing that I really don’t like, but that is coming from a more structured, procedural mindset, is the fact that if you pass local variables to a callback within a Closure, those variables will be essentially global – and taking up memory – where the visibility is restricted to the callback only. In closure – pun intended – this is how Dave summarized the difference between objects and closures:

Objects: Data encapsulating behavior
Closures: Behavior encapsulating data

Dave wrote a book on Ajax Design Patterns and he told the crowd that he advises to not use Java-esque ways to program the GoF patterns but to use a more JavaScript approach. This will prove to have you writing less code and use some of the typical JavaScript constructs to their full potential.

He ended the session by demonstrating the implementation of the MVC and Strategy Patterns in an easy to understand manner.

Even though this turned out to be a more code-centered session, I liked it.

No comments: