Relevance Reviews #2: Ajax Hacks


URL: http://blogs.relevancellc.com/articles/2006/04/09/relevance-reviews-2-ajax-hacks

 

 

This week, I am off to Vancouver to teach Ruby on Rails Today's in-plane reading is Bruce Perry's Ajax Hacks, published by O'Reilly.

Quick summary:Chapters 4 and 9 are excellent and may justify buying. Skip the rest.

The "hacks" format breaks the content of a technical book into (in this case 80) individual entries. As I mentioned in an earlier review, I like this format because like most developers I learn best by example.

Unfortunately, the "hacks" metaphor breaks down in this book. Chapters 1-3 are not really hacks at all; they are mostly a raw-JavaScript Ajax tutorial, disguised as hacks to fit their form of the book. This is unfortunate because inexperienced readers may choose to use "intermediate" steps of the tutorial as "final" hacks in their applications. We have a bunch of great Ajax libraries; very few people should have to write raw-JavaScript Ajax. That said, it is definitely still worth learning raw JavaScript Ajax. You should always understand one level of abstraction underneath your primary work. Once you've learned, pick a library for your production work.

Chapter 4 ("Power Hacks for Web Developers") is much better -- a grab bag of techniques that will have something new for most readers, even if they have Ajax experience. This chapter also benefits from multiple authors, as you get to see different stylistic choices being made. Also, this chapter encourages more thinking about "what can I do?" instead of just "how can I do it?" There are several examples of mashups that combine existing web services under a single Ajaxy front.

Chapters 5-8 cover a variety of Ajax libraries: DWR, Prototype+Rico, Ruby on Rails, and Scriptaculous. First let me say that I think the choice of which libraries to cover is spot on. The only obvious omission is Dojo, and Dojo is so big and ambitious that a chapter overview in "hacks" format would be useless. And that leads me to the problem: These chapters are not collections of hacks, rather they are introductory chapters that have been wrestled into a "hacks" format. All of these topics have much better coverage online and in other books (which I will be reviewing as this series continues).

The Rails and DWR chapters have particular issues: Chapter 7 (the Rails chapter) is way behind on Rails, claiming coverage of Version 0.9.4. Thomas and Hansson's excellent book Agile Web Development with Rails has a more up to date Ajax chapter, despite having a publish date that is nine months earlier. The DWR hacks (Chapter 5) miss almost everything that is cool about DWR. Hack #48 demonstrates accessing a custom object by having the object store values in a Map and do its own toJSON work. There is no mention of DWR's ability to automatically marshal real-world Java beans, which are typically not backed by Maps. Hack #49 commits the cardinal sin of RPC, doing in multiple roundtrips what could be done in one. This is ironic, since DWR supports a batching operation which automates doing the right thing.

Chapter 8 rocks. Read it. Hacks #68 and #69 demonstrate not one, but two, different ways to "fix" the back button in Ajax applications. #70 adds timeouts to Ajax invocations. #75 and #77 begin to embrace the browser as its own MVC environment, creating client side caches and search indices. This is almost the opposite of what most people think of Ajax -- using the flexibility of JavaScript to reduce communication with servers. Finally, my personal favorite, #73, clearly explains how to use dynamic script tags to cheat the browser security model, letting one page invoke services from multiple domains. (Use with caution, of course.)

In summary: Intermediate to Advanced Ajax developers should read chapters 4 and 8, and beginners should read something else.

 

本文作者:



相关阅读:
SQL Server 2005返回刚刚插入的数据条目id值
Fedora 8 Linux系统的内核配置注意事项
把Javascript代码放到body结束之上
phpcms将下载地址替换为图片显示
php csv操作类代码
交互设计最重要的是态度:通过交互来引导用户
让select查询结果随机排
MySQL 错误处理例子[译]
把首行和尾行互换的批处理
Ubuntu Linux设置守护进程时出错的解决
特俗的字 特殊符号打法
javascript程序的执行效率问题
Asp.net中的GridView导出遇到的两个问题和解决方法
10个常见的IE bug和解决方法
快速导航

Copyright © 2016 phpStudy |