AJAX DESIGN PATTERNS IS A REFERENCE FOR DEVELOPERS, DESIGNERS, AND MANAGERS WHO WANT TO know how Ajax is being used in the real world. Ajax is a new label to describe rich, desktop-like Internet applications that run in standard web browsers and do not require any special plugins. Its popularity stems from high-profile Ajax applications like Gmail, Google Maps, and 37signals' Basecamp, and it is becoming popular in the enterprise as well. The patterns in this book fall into four categories. Foundational Technology patterns overview the raw technologies required for Ajax development, such as the XMLHttpRequest object. Programming patterns expose techniques developers have been discovering to ensure their Ajax applications are maintainable and performant. Functionality and Usability patterns are about the kinds of user-interfaces you'll come across in Ajax applications and the new types of functionality that Ajax makes possible. Finally, Development patterns explain the processes being used to monitor, debug, and test their Ajax applications. Who Should Read This Book?You should read this book if you want to:
Because of the reference-like nature of the patterns, the book is accessible to people from different backgrounds. Developers who want to ramp up on Ajax will be able to begin with the tutorial chapter and the foundational technologies. Those who already have some experience with Ajax will probably gain the most from the Programming and Development patterns. People in less technical roles will be able to take a high-level perspective, looking especially at the Functionality and Usability patterns and the Real-World Examples therein to see what's possible with Ajax. To follow the technical discussion and code examples, programmers should have some experience with the basics of web developmentHTML, form submission, server-side scripting, and so on. Ideally, you should know some JavaScript too, as this book isn't intended to teach you the language, but the writing does take into account that many readers will only have basic familiarity with JavaScript. Ajax is mostly about what happens in the browser, so the book doesn't assume you know any particular server-side environment. On those occasions where server-side code is involved, the examples are PHP-based and always explained in language-neutral terms. Who Should Not Read This Book?If you haven't performed any web development work, you're probably better off looking for an introduction to the basic concepts before jumping into Ajax and these patterns. Ajax development involves working with a broad range of technologies, including HTML, XML, CSS, JavaScript, and server-side development. This book will help you understand how Ajax relates to each of these and how they are often combined together, but if you're looking to learn any one of these in depth or you're seeking a reference on browser specifics, I'd recommend consulting a specialized text. About the ExamplesAll the examples in this bookthe tutorial code as well as the Ajax Patterns code examplescan be downloaded from http://ajaxify.com/run. They've been developed to be compatible with recent versions of Firefox and Internet Explorer (IE), and have been tested on Firefox 1.5 and IE 6.0.[*] Most of the server-side code requires PHP 5 or later and was tested on PHP 5.0.4. The PHP code should run on any standard web server capable of running PHP scripts; Apache 1.3.33 was used for testing. The Wiki Demo requires MySQL and was tested on version 4.1.14-max. See Appendix B for information on installing the demos.
Browser SpecificsTrue to the aims of Ajax, all of the Ajax Patterns are implementable in any modern, standard browser, and the discussions focus more on issues of general architecture and usability instead of browser specifics. However, portability issues do arise in some cases and are addressed where they are critical to implementing the pattern (as in some of the topics in Part II, Foundational Technology Patterns). To maintain a high-level focus, most of these discussion are still limited to IE and Firefox; it's beyond the scope of the patterns to outline the idiosyncracies of each browser and version, for which a specialized reference is advisable. Organization of This Book
Conventions Used in This Book
The term "the browser" is shorthand for the entire system at the browser endnot only the browser application (e.g., Firefox), but also the web application running inside it (e.g., Google Maps). When I'm talking about the browser application, I'll usually call it a "web browser"it's fairly obvious from the context anyway. Likewise, "the server" or "the server side" refers to everything on the serverthe operating system (e.g., Linux), the web server (e.g., Apache), as well as the application-specific scripts running within. The terms "ECMAScript" and "JScript" don't appear"JavaScript" is meant to cover these terms. The term "class" is used to describe JavaScript functions that are used in a manner similar to classes in object-oriented systems. The first figure that appears in each pattern's section is an illustrated overview of that particular pattern. Some common acronyms used throughout the book are:
Conventions in Code ExamplesDesign diagrams are based on Universal Modelling Language (UML) notation, though less formal in most cases. In the code examples, a .phtml suffix is used for PHP files that output HTML; all other PHP files (such as business logic modules) end in .php. As illustrated in Chapter 2, $( ) is aliased to document.getElementById( ) to reduce code clutter (inspired by the prototype librarysee http://prototype.conio.net/). Some code examples have been reformatted for the sake of clarify. Safari® EnabledWhen you see a Safari® Enabled icon on the cover of your favorite technology book, that means the book is available online through the O'Reilly Network Safari Bookshelf. Safari offers a solution that's better than e-books. It's a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari.oreilly.com. How to Contact UsPlease address comments and questions concerning this book to the publisher:
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:
There's also web page for this book, containing full draft text for all patterns and links to an increasing collection of audio podcasts about the patterns. In addition, you'll find information on various Ajax resources and errata for this book. The web page is located at:
To comment or ask technical questions about this book, send email to:
For more information about our books, conferences, Resource Centers, and the O'Reilly Network, see our web site at:
AcknowledgmentsWriting this book online means I received lots of excellent feedback throughout the process and have many people to thank. Which is another way of saying it's highly probable I'll leave someone out! If that's the case, please mail me any corrections. My editor, Simon St.Laurent, has always been quick to respond to my queries and dealt admirably with a book being written in a somewhat unusual manner. Thanks also to proofreader Mary Brady for leaving no stone unturned, and illustrator Rob Romano for helping to make the content accessible at a glance. I also want to express my appreciation to O'Reilly for taking on the Ajax Patterns and especially for letting me write the book online, and blog and podcast about the content without restriction. The book grew from a blog post on Ajax Patterns (http://softwareas.com/ajax-patterns), and it was the insight of Thomas Baekdal to cover Ajax usability principles that inspired to the initial patterns post (http://www.baekdal.com/articles/Usability/XMLHttpRequest-guidelines). I also have Brent Ashley to thank for his discussing the patterns at the initial Ajax summit and in his blog, apparently the trigger for the initial ripple of online interest in the project. The ideas in this book also owe a great deal to Jesse-James Garrett and his seminal Ajax article, without which you would not be reading these words. All the book reviewers provided valuable feedback on the online version throughout the writing process as well as offering many detailed comments on the book's draft version. The reviewers were: Cameron Shorter (ADI Limited, Mapbuilder) and Kevin Vinsen (ADI Limited), whose employer, ADI Limited, provided time for them both to conduct the review; Jep Castelein (Backbase), Daniel Czarnecki (Zoltak Consulting), Tony Hill (Thomson Corporation), and Alex Kirk (Blummy.com, WizLite.com). In addition, a big thanks to members of the Software Architecture Group (SAG) at the University of Illinois at Urbana-Champaign for conducting several rich discussions on the patterns and making the audio publicly available (http://www.softwareas.com/sag-ajax-patterns-review-1)the comments certainly made a difference as the editing moved into its final stages. Ralph Johnson, who leads the group, nominated the Ajax Patterns for review, and Brian Foote kept me informed throughout the process. I'm also grateful to everyone who added to the public portions of the AjaxPatterns.org wiki and offered feedback on the online draft via email, blog comments, and in wiki discussions. As the patterns were discovered from many existing applications, I would like to thank the creators of all the examples featured in the pattern descriptions, many of them true pioneers. Special thanks to those developers who explained aspects of their designs to me: Kevin Arthur (Stream), Richard Cowin and Bill Scott (OpenRico), Donovan Preston (LivePage), Jeremy Ruston (TiddlyWiki), and Tino "Crisp" Zijdel (DHTML Lemmings). The patterns are also based on numerous writings, code dissections, ideas, proofs-of-concept, and direct suggestions. In particular, a number of patterns are only here because of the contributions of the following authors and developers (also mentioned in individual pattern descriptions): Julien Couvreur, James Dam, Abe Fettig (Twisted, Jotspot), Chris Justus, Christopher Kruslicky, Alex Russell (Dojo, Jotspot), Richard Schwartz, Mike Stenhouse, Joel Webber, and Chris Were. In addition, there were several news-focused services that made it a lot easier to locate all this content as it happened (and also helped other people find AjaxPatterns.org!). Among these resources: Niner Niner's AjaxBlog.com, Chris Cornutt's AjaxDeveloper.org (Chris is now with Ajaxian.com), Dion Almaer, Ben Galbraith, and Rob Sanheim at Ajaxian.com (disclaimer: I've since joined the Ajaxian team), Shane Witbeck's AjaxMatters.com, Mike Papageorge's FiftyFourEleven.com, Brian Benzinger's SolutionWatch.com, and Mike Arrington's Techcrunch.com. Last but not least, heaps of gratitude to my family for their support throughout the writing process. |