《Ajax修炼之道》的一则讲述Hector开发团队所要面向新的开发架构-Ajax的故事
A Tale in Three Acts Hector is a project manager for a web application development shop. With a long history of Perl, CGI, ASP, Servlet, and JSP development under his belt, Hector’s been around the block. For the last year his team has been building a CRM application for a large Fortune 500 company with offices all over the world. The application used to be a greenscreen mainframe application; the company wants to take advantage of the great reach of the Internet to deploy the application to every office. Hector and his team focus a lot of their energy on the server side of the application. They have been using one of the modern MVC frameworks from the Java community to implement the business logic, a high-performance persistence framework to access the database, and messaging-based infrastructure to connect to other existing systems.
Yesterday On the client side, Hector and his team have become masters of CSS. The look of the pages bends to their will; when the customer wants rounded corners, they get rounded corners. Rollover colors? That’s easy. Multiple color schemes? No problem. In fact, Hector and his team long ago reached a point where they weren’t really worried about the user interface. See, the Web operates one way: it essentially distributes static documents. When users want more data, they incur a complete interface refresh. It isn’t optimal from an efficiency perspective, but it’s how the Web works, and users have just learned to live with it. Then, sometime a couple of weeks ago, Hector’s customer came to a meeting. The customer was usually a polite, accommodating fellow. He understood the Web, and he understood the restrictions he had to live with to get the reach of the Internet. In fact, Hector had never seen him get really angry. Until this meeting. As soon as he walked in, the team knew something was up. He had his laptop with him, and he never carried it. As he stormed into the room, the team glanced around the table: what have we done? The customer sat down at the table, fired up the laptop, and hammered away at the keyboard for a minute. While he pounded the keys, he told the team, “Last night, my wife and I were invited to a party at the CEO’s house.” “Uh oh,” thought the team, “this can’t be good.” “Well, I certainly jumped at the chance,” he continued. “I’ve never been before. This project got me on his radar.” (“Double uh-oh,” thought Hector.) “When I couldn’t figure out how to get there with my city map, I went to the Internet. I found THIS!” He hissed the last word with venom and scorn. He flipped the laptop around so the table could see it. There, quietly couched in his browser window, was Google Maps. “Why,” he said, through clenched teeth, “can’t I have this?”
Today Since that meeting, Hector and his team have been rethinking the user interface. Hector went out to learn how Google could have completely ignored conventional wisdom and generated such a thing. He came across an article by Jesse James Garrett describing this thing called Ajax. He has been digging since then, learning everything he can about this new way of making Internet applications. The team has begun reimplementing the UI. They’re using JavaScript and DHTML techniques to provide a more dynamic experience. Most of all, they’ve begun taking advantage of a useful object available in modern browsers called XMLHttpRequest (XHR for short). This handy little guy lets Hector and his team request and receive fresh data from the server without reloading everything in the page. In other words, Hector spearheaded a move from Web 1.0 to Web 2.0. And his customer is happy again.
Tomorrow So what comes next for Hector? His team is learning a bunch about JavaScript, XHTML, and even more about CSS than it ever knew before. The team is really excited about the results: the user experience is just like any other application now, except the team doesn’t have to manage an installer as well as the application itself. But they’ve realized that there’s a downside to all this. Now, they are writing a ton of code in JavaScript. It turns out that all this page manipulation and XHR access requires a lot of real, honestto- goodness code. And even though JavaScript looks a lot like Java, they’ve discovered that it really is a different beast. And now they have two codebases to manage, test, and maintain. So Hector is off to find out how to solve these problems. And what he will see is that most web application development frameworks are rapidly incorporating Ajax tools into their own suites. Soon, Hector and his team will be able to leverage Tapestry components, Spring tag libraries, ASP.NET widgets, Rails helpers, and PHP libraries to take advantage of Ajax without having to incorporate a second way of working. The (near) future of Ajax development is total, invisible integration. And this is exactly what Hector needs.
|