Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Book Reviews Books Media

Ajax Design Patterns 39

pankaj_kumar writes "A number of AJAX libraries and frameworks have emerged to purportedly simplify development of rich Internet Apps. None of them however can substitute a good understanding of what the recurring problems are, the potential solutions and what goes on behind the sleek facade of a browser to power these Apps . Michael Mahemoff, author of Ajax Design Patterns, said this best in his blog which became a popular wiki entry and later, this book." Read the rest of Pankaj's review.
Ajax Design Patterns
author Michael Mahemoff
pages 635
publisher O'Reilly
rating 9
reviewer Pankaj Kumar
ISBN 0-596-10180-5
summary Creating Web 2.0 Sites with Programming and Usability Patterns


The Ajax Design Patterns book, with its more than 70 design patterns, documented in more than 600 pages with encyclopedic detail, is very effective in presenting the AJAX programming knowledge in a reader friendly format. In the spirit of seminal GoF Design Patterns work, it captures the essence of each of the topics with problem solving approach — first stating the problem in general terms and then presenting the solution, outlining the approach and discussing variations, alternatives, trade-offs and even listing actual uses in real applications. Btw, if you noticed I used the term topics in the previous sentence to refer to its 70+ "knowledge modules" and not patterns, mostly because I wouldn't categorize all of them as patterns. However, this disagreement on terminology doesn't take away anything from their practical usefulness and, for sake of consistency, I would continue calling them "design patterns".

A bit on scope and level of material presented in the book — most of the material is quite advanced and assumes good knowledge of technologies for writing web based applications: HTTP, JavaScript, (X)HTML, CSS, PHP and a bit of W3C DOM. The code fragments, and there are quite a few of those, are in JavaScript (for client side) and PHP (for server side). Most of the prominent AJAX libraries, toolkits and frameworks are also mentioned, often while discussing a particular pattern as a reference of actual use. The appendix lists them all at one place and highlights their main features. Though, the book carefully avoids to recommend any one as 'The AJAX toolkit'.

The book categorises the design patterns as Foundational Technology Patterns (those related to repainting the user interface, browser and web server communication, and event handling), Programming Patterns (those related to programming aspects of either end, browser or the service, of the application), Functionality and Usability Patterns (those related to functional widgets such as slider, data grid, progress indicator etc., page layout, visual effects and so on) and Development Patterns (those related to debugging and testing). Of course, the real value is in the details of each pattern, and not just the high level categorization or overview.

A reader of this review may be interested in knowing why should he or she buy the book when most of the content is freely available at the Ajax Patterns Wiki. Here is my take on this: although most of the content is available on the Wiki, the text in the book has gone through professional editing and is more readable. Also, the description of most of the patterns run into multiple pages, and it becomes hard to read long articles while connected to the Internet (I tend to click on links and wander away). As an additional bonus, the book includes illustrative diagrams, which I found quite helpful, and at times, funny. Most of the patterns included in the book taught me something new, I did end up with a list of favourites after finishing the book in less than a week: XMLHttpRequest Call: One of the most comprehensive treatment of XMLHttpRequest object and its various use patterns, limitations and alternatives. On-Demand JavaScript: How to do lazy loading of JavaScript code to improve responsiveness or get data from a different server. HTTP Streaming: How can a server keep sending data to the browser over an HTTP connection initially established by the browser. Call Tracking, Submission Throttling: How to protect your server from excessive load by very active users without compromising responsiveness. Browser-Side Cache: Ajax doesn't solve the inherent latency problem of the Internet. You still need the good old tricks to improve the user experience. Malleable Content: How to let the user edit some information on a mostly read-only page. One-Second Spotlight, One-Second Mutation: How to communicate change in a portion of the page without being obtrusive. Direct Login: How can you improve the user experience as well as the security of authenticating user using Ajax and JavaScript wizardry. Unique URLs: Going Ajax should not require your users to abandon joys of hyperlinking and the old and tried habits of navigating content by clicking on the familiar back and forward buttons.

So far I have only been talking about things that I liked but there are some things I would consider weak spots. I noticed a few minor typographical issues with certain code fragments, but they are rarely serious. For example the first code fragment on page 96 has uses variable requestTimer to store the return value of setTimeout() and then uses variable requestTimeout as argument to clearTimeout().

A good addition for a future edition could be patterns on AJAX program performance during development, deployment and runtime such as JavaScript compression to improve download times and execution speed and considerations on using multiple third party JavaScript libraries.

Another thing I found a bit annoying at times is presence of a lot of URLs all over the text with hints too brief to allow uninterrupted reading away from the computer. I would have preferred numbered footnotes, either in each page or at the end of each pattern, with URLs and a brief summary of its contents. Usually I read printed books when away from the computer and do not wish to go to the computer and type-in the URLs to just understand what is being said in the text. Although immensely helpful during online viewing, the embedded URLs are a hinderance during offline reading. This is one area where the structure of printed content should be different from the online content.

Overall, I would recommend the Ajax Design Patterns to all those who work or aspire to work on web development projects as an excellent reading and reference resource.


You can purchase Ajax Design Patterns from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

Ajax Design Patterns

Comments Filter:
  • In my opinion, Spaghetti design pattern is the most important AJAX design pattern:
    It may look like a mess. But, it works somehow and it tastes good as well :)

    • Plus, you wouldn't want everyone analyzing you JavaScript code and figuring out how your application works.
    • Ugh, I thought we were rid of the term "AJAX" by now.
  • I think Ajax is a beautiful thing. I really do think the web has taken a turn for the better with sites like yahoo [yahoo.com], Flickr [flickr.com] and Grapheety [grapheety.com].

    The latter being an example of something that really could not exist with Ajax. Amen! :)

  • by mandelbr0t ( 1015855 ) on Wednesday January 10, 2007 @04:26PM (#17545336) Journal

    However, this disagreement on terminology doesn't take away anything from their practical usefulness and, for sake of consistency, I would continue calling them "design patterns".

    ...Because the seminal GoF work called them "design patterns". And in that book, they most certainly are. I just don't put Usability "patterns" in the same category as the GoF patterns; the scope and abstraction of the recurring problems are not even close to being on the same level. I don't think that it's about "consistency", but rather a simple word play to put AJAX programming on the same level as C++. Sorry, AJAX just isn't that complicated, and trying to make it sound big and complicated is just more Web 2.0 hype. Besides, who needs a book to learn AJAX? Unless I missed something important, a few paragraphs and a couple code samples explain things just fine.

    mandelbr0t
    • Re: (Score:3, Insightful)

      by boldtbanan ( 905468 )
      And that's really what this seems to present. The designs described on the associated website (I haven't seen the book) aren't "patterns" in the OO/GoF sense but more like templates/methods for solving specific problems. I think the author is using "patterns" as a buzzword here to draw more attention.
    • Sounds like "recipes" might have been a more appropriate choice of words.
    • by Bogtha ( 906264 ) on Wednesday January 10, 2007 @05:14PM (#17546244)

      I just don't put Usability "patterns" in the same category as the GoF patterns

      Just because they are applied to a different concept, it doesn't mean that they aren't patterns. If you object to the leap from programming to usability, then surely you must also object to the term being used for programming in the first place, seeing as the term "design pattern" originated not in computing, but rather in architecture [wikipedia.org].

      The basic concept of a design pattern is that there's a standard approach to solving a common problem, and you describe it and name it. By giving them names, you can talk about the thing you are working on at a higher level and you don't need to worry about the specifics as much when thinking about the overall project architecture. The term "design pattern" is valid for many different areas, basically anywhere where there's something too complex to keep entirely in your head in one go. As part of a web application, various solutions to usability problems certainly qualify for the "design pattern" moniker.

    • by GOD_ALMIGHTY ( 17678 ) <curt DOT johnson AT gmail DOT com> on Wednesday January 10, 2007 @07:00PM (#17548148) Homepage
      Sorry, AJAX just isn't that complicated, and trying to make it sound big and complicated is just more Web 2.0 hype.

      AJAX is distributed computing. Distributed computing is hard. Ergo, AJAX is hard. If you're building a real application and not just adding flaming and spinning icons to a web page, you are doing nothing conceptually different than any other remote procedure call. The problem is, most people don't know how to write software in any language that handles that environment well. I know because I usually come in an clean up after them. I've had to do it in just about every language and with every rpc protocol. It's the same mistakes everytime. Your comment is like saying C++ isn't that complicated because it's Java without automated memory management. First of all, AJAX is a PITA to debug, you may have to step through code in a number or separate environments in order to debug a single round trip, like all rpc calls. GWT makes this easier, but that's done by having the programmer develop the client side code in the same environment as the server side code and coming with it's own special debugger. Avoiding more debugging and having to debug really hard to find problems is the point of understanding patterns. I'd much rather see the new AJAX dev on the team reading this book instead of AJAX in 24 hrs or something.

      Besides, who needs a book to learn AJAX? Unless I missed something important, a few paragraphs and a couple code samples explain things just fine.

      Ok smarty, which AJAX framework would you choose? GWT, J2Script? Would you handroll your own? What sort of data structures were you planning on using to get the data across the wire? Should your AJAX calls be fewer in number with larger payloads or would your application benefit from many calls with small payloads?

      The AJAX environment may not cover the scope of the C++ one, but that doesn't mean that anyone is going to walk in and start using it properly. I doubt you can claim that you've never had to scrap an unworkable design. Due to AJAX's limited scope and nature, rpc calls from JavaScript, it is entirely appropriate to emphasize good distributed computing patterns. It's no different than a book on CORBA in C++ that discussed patterns. Web Services, both AJAX and SOAP, are CORBA and RPC all over again. That's why SOA is just Same Old Architecture. The patterns are mostly the same, it's just different capabilities and different transports.
      • Obvious flamebait, but what the hell.

        AJAX is distributed computing. Distributed computing is hard. Ergo, AJAX is hard.

        AJAX is a tiny component of the overall distributed application. The distributed application is not written in AJAX. AJAX isn't even a language; JavaScript is. Maybe some people who write AJAX code actually wrote some RPC stuff too, but I'd wager they're just a 13-year-old web monkey. RPC is distributed computing. RMI, CORBA, even XML web services are distributed computing. JavaScript is just glue. Get over it.

        Ok smarty, which AJAX framework would you choose? GWT, J2Script? Would you handroll your own? What sort of data structures were you planning on using to get the data across the wire? Should your AJAX calls be fewer in number with larger payloads or would your application benefit from many calls with small payloads?

        I'd roll my own. If I really needed to write an applicat

        • Re: (Score:3, Informative)

          Nah, that wasn't flamebait. That was just some guy disagreeing with you.

          Now THIS is flamebait: Your post sounds like it comes directly from the "I've never done it, so it can't possibly be hard" school of thought.

          See the difference? In the latter instance, I'm questioning your competence in a none-too-subtle manner, in order to evoke a heated emotional response. Aside from the "Okay, smarty" (which seemed pretty justified given your apparent belief that AJAX techniques can be fully mastered in fifteen m
        • by GOD_ALMIGHTY ( 17678 ) <curt DOT johnson AT gmail DOT com> on Wednesday January 10, 2007 @09:44PM (#17550280) Homepage
          AJAX is a tiny component of the overall distributed application. The distributed application is not written in AJAX. AJAX isn't even a language; JavaScript is. Maybe some people who write AJAX code actually wrote some RPC stuff too, but I'd wager they're just a 13-year-old web monkey. RPC is distributed computing. RMI, CORBA, even XML web services are distributed computing. JavaScript is just glue. Get over it.

          In the day and age where I have clients who all now want web apps, but still want all the functionality of a desktop app, you better believe AJAX and this Web 2.0 crap is here to stay. AJAX is also going to stay because the tools are better. I've been avoiding Javascript for years, I can't stand figuring out all the browser quirks, I'd much rather write a Swing app. Google's Web Toolkit changed that. It's a seamless framework for cross-browser applications, I can use CSS to style my UI and Swing like components in a Java IDE to write the actual code. The lack of decent tools is why CORBA didn't take off. Hello World is no less complex in AJAX than CORBA or RMI, it all has to make it across a network and back. It's just that the tools are better, which was probably helped by the lack of complexity in the underlying protocol, but c'est la vie. The web browser is now a rich client. You may believe HTTP is a most horrid protocol for doing RPC or that Javascript is a most horrendous environment for writing anything other than hello world, and I would agree. Like I said, this is all simple CORBA again, but with a universal client app container (the javascript/dom/css capable xml browser) instead of a hand coded top-to-bottom desktop app.

          Why wouldn't it make sense to do it this way? We've moved to application containers on the server end to instrument applications with basic infrastructure, why not do it on the desktop too? How is a data structure serialized via a Javascript call to an HTTP request that returns another data structure in an HTTP response any different from RMI, CORBA, MSRPC, XML-RPC or SOAP? Same basic process, so what if Javascript is just glue? By that premise, so is every other language that uses C libraries. Javascript is a scripting language that can be used to draw interactive UI's. The fact that Javascript is not really a great environment to write really interactive UI's doesn't change that. How is GMail any different from early desktop email clients? And I don't even have to actually touch the Javascript if I use existing GWT components, I can write the whole damn thing in Java.

          I'd roll my own. If I really needed to write an application that constantly transferred huge amounts back to the client, it'd probably be a clue that a proper desktop client/server app would be a better architecture.

          Personally, I'd recommend GWT for Java devs, but to each his own. My question is what if your client requires a web based app? Are you going to tell them you're only going to write that kind of app in a proper desktop environment? CORBA was a damn good architecture too, but how many CORBA apps to I get paid to write? And it's not like our company wouldn't win the work, we've got several people who've rolled their own CORBA orbs. AJAX is here to stay because it fulfills the requirements today. Half the crap on teh Intarweb today would be kicked off if my view of engineering aesthetics were adhered to.

          I mean, most AJAX people don't even realize that the server-side input doesn't need to be written in XML. Guess what? if you're receiving so much data back from the server as to need to process huge XML documents, it's just a fast to do a post-back.

          You are correct here. That's why I'd recommend a framework, better not to confuse them with your hand rolled hiding of all this. After all, you don't intend on maintaining this thing forever do you? It's also the reason I like CORBA over SOAP, that and SOAP is freaking reinventing every CORBA spec out there, It's not like the CORBA way is any more painful or that the tools couldn't be written just as easi
    • Re: (Score:3, Informative)

      by Tim C ( 15259 )
      I just don't put Usability "patterns" in the same category as the GoF patterns

      That's because you don't know what a pattern [cambridge.org] is. Note that nothing in that definition, that a pattern is "a particular way in which something is done" in any way references computing.

      A pattern is a way of doing something, a common solution to a common problem. That even applies to knitting patterns - the problem is that you have wool and no jumper, you follow the pattern, you have a jumper. Nothing about the GoF book makes them C+
    • Re: (Score:3, Informative)

      by mahemoff ( 1049494 )
      Hi, this is Michael, the author of Ajax Design Patterns. I won't repeat what others have said already regarding the broad definition of patterns that this book assumes. Suffice to say, patterns didn't start with GoF and in fact, the basic idea - documenting common solutions in a consistent format - has been used in way or another for many decades, predating even Alexander's work. Here, I'd just like to add a couple of clarifications:
      • I understand where you're coming from if you consider the title to be stu
  • by Naum ( 166466 ) on Wednesday January 10, 2007 @05:15PM (#17546264) Homepage Journal
    To date, IMV.

    Unfortunately, I've plunked down money for a bunch of hardcopy books on AJAX and the new fangled javascript tidings — yes, I know I could find most of the requisite documentation online and/or I even question the silliness of amassing a library over a simple API call and a few demonstrative examples. But if I were to choose one book to buy or keep on the subject, this would be the one, easily.

    Why? Well, because the author takes a problem centric view after a basic tutorial (i.e., how to handroll your own remoting, simple code examples). Then, all the things you can do with the tools are detailed, within a templated question and answer framework, and unlike the reviewer here, I appreciated the inclusion of all the URLs so I could research further. Also, a big part of learning anything is just getting the terminology down, so that those can serve as "keys" for subsequent knowledge acquisition. Also, the author doesn't seem mentally tied down to a given platform (take note .NETers and Rubyists) and explains things from a purely algorithmic perspective.

    This is a worthy title for anyone wishing to expand their AJAX knowledge, though if you're totally comfortable with online discovery, you could forego it.

  • Whacky AJAX (Score:3, Interesting)

    by dino213b ( 949816 ) on Wednesday January 10, 2007 @05:44PM (#17546828)
    More I learn about it, less I want to use it..which is a conundrum because I am developing a project especially meant to use it. It seems that AJAX goes well with entire GUI toolkits so I started with simple transactions and then eventually fell victim to all the shiny features of Dojo - and then got horrified when things started acting like they shouldn't. For example, a nested element causes a to lose the cursor while typing. I don't know how to resolve that -- but -- going back to the drawing board ought to be the way to go.

    What are some of your experiences with using AJAX toolkits like Dojo?
    • Re: (Score:3, Informative)

      by elbobo ( 28495 )
      My take on DHTML widget toolkits is this: It's too soon.

      Even the low level toolkits are still in their early stages, shaking out the initial design concepts and best approaches. So the situation in the higher level/GUI toolkits is going to be much worse. There's a very high risk of investing considerable code and project time into a toolkit only to discover that either it just doesn't fit with the project, or that the toolkit is still too quickly evolving to be a stable target.

      That rapid evolution is a symp
    • Re: (Score:2, Interesting)

      by wranlon ( 540319 )
      I spent a lot of time between '99 and '02 developing an DHTML toolkit [imnmotion.com] (example [imnmotion.com]). In the summer of 2002 I started working on a rewrite of the widget toolkit, and ultimately created something else - Engine [imnmotion.com]. I wrote an article about the decisions that lead me from the widget-heavy MDI toolkit to service and component orientated Engine toolkit: The Separation of Functionality from Content [imnmotion.com]. Dojo, and the other toolkits that are pretty similar to it, have a lot of neat aspects and very clever widgets. However
    • Re: (Score:3, Insightful)

      by Shados ( 741919 )
      My experience with AJAX toolkits, is probably going against Slashdot's ideology, but for the sake of giving diverse arguments: the web is a complex world, full of bugs, mishaps, problems (even in the best browsers), and intimate knowledge of all of em is required to do complex (very complex) things. That is simply not something anyone but the most dedicated programmer can do as a hobby.

      In other word, for a long time, commercial backup will be required. That means things like ASP.NET Ajax (Atlas. Note: Micro
    • I stick to simple libraries that abstract away the guts of browser type and the mechanics of XMLHttprequest, and give me something I can return an array of data from the back end to do with what I wish. Having said that, I generally only use a smattering of AJAX to facilitate the use of a page - though it's definitely essential, and my apps could not compete with desktop apps at all without the functionality that AJAX provides. I've found that scripting the DOM manually really isn't that tricky if you're
  • AJAX Patterns [ajaxpatterns.org]
  • From the review, looks more like it should be called BORAX Design Patterns because every time I hear the term AJAX I find myself involuntarily yawning.
    • From the review, looks more like it should be called BORAX Design Patterns because every time I hear the term AJAX I find myself involuntarily yawning.

      Then you'll love "Agile Ajax Design Patterns 101 in Seven Days for Dummies in a Nutshell Super Bible Unleashed for Web 2.0"
               
  • heres a pattern:
    First comes the "next cool way to do it."
    Then comes the ide.
    Cue the testing tools.

    Untill theres a library way out in front, I'm just gonna keep learning selenium [openqa.org].

  • I bought this book. Wanted Ora's with same title, but could not find such. So picked this one after long comparsion and once i got it, it was a real disappointment. Writing style, content, etc, this guy should not be writing books.


    The reason why Ora doesn't have such is that AJAX is basically Javascript topic, you don't need a book for it, nor you can't write one. Buy a good javascript, XHTML, XML, CSS book and you are fine.

    • I think you're talking about a different book, because this is an Ora book (one of several ORA books on Ajax - there's also Ajax Headrush and Ajax Hacks).
      • by netpig ( 37704 )
        Auts. You're right. Mine is 'Ajax Patterns and Best Practicies' from apress.com.
        (ISBN: 1-59059-616-1)

        Doesn't change the fact that this is worst book I've bought. :-(

"If it ain't broke, don't fix it." - Bert Lantz

Working...