views:

65

answers:

3

A passionate discussion from today.

Developer 1: "AJAX is a set of tools, use it where it really helps, not just for the sake of it."

Developer 2: "Its almost 2011, we can build rich desktop like applications in the browser, we should use AJAX everywhere and make a single page application with everything in it an AJAX powered component."

I can understand things so far. Here's where I don't get it.

Developer 1: "Using AJAX to make a single page app, we will have to write our own code to manage bookmarking and browser back forward buttons"

Developer 2: "No problem, that's easily doable. It's worth it because AJAX solves the problems we had with normal GET/POST, the statelessness. With a one page AJAX app, you can maintain context, you don't need hidden variables, heavy session management as you would when you moved between pages"

Is Dev 2 right? Has AJAX really solved problems with how the 'web' normally works?

+2  A: 

No.

First of all, there's no problem with how the Web works. It was designed to be stateless, and even with a single page AJAX app, the Web is still stateless.

The problem is with how Developers approach managing state in the stateless environment of the web. Single page AJAX applications definitely make managing state much easier for developers (actually, it sidesteps the problem entirely) that are used to being able to manage state easily in a desktop application.

Just remember, though, that if you have a single page AJAX application and you forget to send the state back to the server for persistence, you lose it...

In my personal opinion, single page AJAX applications also have code management/readability/maintainability issues that far outweigh the state management benefits. I'd rather learn how to properly pass state from page to page in my application that deal with the headache of a single page that contains all of my code.

Justin Niessner
+1  A: 

You answered your own question with: "AJAX is a set of tools, use it where it really helps"

AJAX has solved a lot of problems by streamlining user experience and allowing the developer to control the flow server-side and client-side scripting. There is a development cost to utilizing AJAX to its maximum potential that its viability is dependent on the project, requirements, performance expectations, etc.

Node.js is very likely to revolutionize web development and web scripting as well. If there is a long-term scope to web development projects, keep the cost-benefits of upgrading to future technologies in mind as well.

Ethan T
A: 

There is a time and place for everything. Writing web pages to not load a new page AT ALL 90% of the time is not appropriate. Certainly there are exceptions for web applications such as Google Docs etc... but AJAX solves a need, and that is "I only want to update a small portion of my page, I don't need to load the entire page again."

You have to understand the needs of your users with the realization of expectations. If I make a comment, I do not really expect the entire page to load again. It's not necessary. If I want to visit another article on the page then I would expect it to go to a different page entirely.

Do not think of AJAX as an all or nothing solution. It fits specific needs just like traditional web pages do, and the two can be married to perfection if that is understood. Otherwise you end up having to write code for a solution to a problem that does not normally exist.

methodin