Jim McCabe had a question for the community, so we thought it would be good to hear your thoughts:

Over the past year or so I’ve gradually integrated AJAX into a web
application. While this is great for our customers, I’m increasingly
disturbed by the ugliness of the code on the server side. We have nice
Java objects representing various components, but the code for those
components is getting uglier by the month. Java that writes HTML was
bad enough. Java that writes JavaScript is even less readable.

I’ve been looking around for information that would help me approach
this problem better but can’t find anything that really discusses this
specific problem. Are there design patterns that help? Are there
libraries that help Java build JavaScript, or even just any good
suggestions on how to keep things readable and clean?

There are many directions that you can take this, and there are many takes on it:

  • “I hate JavaScript”: These frameworks abstract away from the JS itself so you don’t care about it. GWT and RJS are two very different examples here
  • Finally. web services matter: You can code the server side to speak web services, and then the client is responsible for doing the right thing, and both are very separate layers.
  • JavaScript everywhere: Imagine if you just coded in JavaScript throughout the tiers. The client/server piece could blur, and you could share the object model. This could make offline simpler. A framework could be smart enough to grok annotations of methods to know when to go back or not. Of course, we don’t want to make the same mistakes as distributed object systems.

Do you have any advice for Jim?

Source: Ajaxian
Original Article: http://ajaxian.com/archives/ask-ajaxian-are-there-clean-techniques-for-writing-javascript-on-the-server

Leave a Reply

You must be logged in to post a comment.



Site Navigation