Archive for March, 2006

AJAX Travelogue (Part 1): The Pilot

March 17, 2006

There’s hardly ever been a term in software development which has been picked up, digested and (ab)used as fast as AJAX (Asynchronous JavaScript and XML). Thirteen month after the acronym was coined by
Jesse James Garrett
there are more than 20 English books listed on the topic, many of them already in print.

My personal dive into the AJAX sea took place early this year when I tried to come up with a simple demo application to show the practices and pitfalls of Test-Driven Development with SAP’s Netweaver technology. My colleague Marco and I decided to use two technologies to show the universal applicability of our approach: WebDynpro (the SAP way to generate web user interfaces) and plain JSPs.

It didn’t take me long to realize that WebDynpro was going to be a real pain in my behind, so I kept morale up by adding a couple of AJAX features (inline editing, drag&drop, no page rerendering etc.) to the JSP variant. Although I had done some reading on AJAX implementation techniques and patterns, I ended up with a solution of almost 500 lines unreadable JavaScript code, which – to make things worse – only worked with my specific version of Firefox.

So I decided to do it right for once. My goal was to implement the same thing over again, but additionally I intended

  • to leverage the best Javascript and Ajax libraries available.
  • to have automatic tests for both server-side and client-side code.
  • to make standard stuff (like communication and dom handling) as easy as possible.
  • to come up with a cross-browser-enabled solution.

In case you wonder, these are the exact goals of many of the 500+ existing AJAX frameworks.

Being the thorough guy that I am once in a while I started by purchasing (and reading) a couple of books:

Additionally I subscribed to Ajaxian which IMO is a very convenient place if you want to learn latest news about Ajax technologies, libraries and applications.

In the stories to come I’ll probably ramble about lots of details like client-server communication models, browser (in-)compatibilities, JavaScript effects, testing, templates and a few more. For today I send you to bed with the most striking lessons I learned in the last two months:

  • If you want to make a really cool Ajax application, you won’t get around programming in JavaScript. You’ll probably be able to make use of many useful libraries for communication, effects and widgets. But that only gets you so far.
  • JavaScript is not a bad language per se. What really sucks is the bad support for debugging and testing. I have yet to know a JS debugger that works with the latest version of either Firefox or Internet Explorer. The JS interpreters in Firefox and IE are not even able to recognize all syntax errors or to produce sufficient error messages from compilation and runtime errors. IE doesn’t even tell you about the real line number in which an error occurs.
  • Browser incompatibilities slow me down much more than I would have guessed from reading the books. Although I’m using libraries which are supposed to hide the cross-browser issues I spend at least a third of development time to sort out the problems when getting Firefox ready code to work in IE. And I haven’t even tried Opera and Safari yet.

The produce that I accomplished during the last two months (working mostly in the evening and on weekends) is a little framework called JayJax. There’s no release yet, but there will be one soon. And I will present you all my lame excuses why I just couldn’t resist writing yet another one…

Johannes

On broken windows, garbage and everything

March 15, 2006

You might have heard about the Theory of Broken Windows first formulated in an article by James Q. Wilson and George L. Kelling:

“Consider a building with a few broken windows. If the windows are not repaired, the tendency is for vandals to break a few more windows. Eventually, they may even break into the building, and if it’s unoccupied, perhaps become squatters or light fires inside.”

As far as I know, Andy Hunt and Dave Thomas
in The Pragmatic Programmer have been the first to transfer this principle into software development stating that you have to clean up your code often enough to prevent others who see that code from adding more broken stuff. So far so good (or bad, actually).

During the last weeks I have been witness to a slightly different expression of the same principle. I live in Heidelberg, Germany, a city rather well known for its mediaeval buildings, its tiny alleys and its being cleaner and more innocent than most German cities. Since the garbage collection service has been on strike for over a month now, Heidelberg’s tidiness has somewhat suffered. You can see large piles of garbage everywhere, growing larger from day to day. Garbage attracts more garbage.

I cannot help realizing that by now many (if not most) people have given up completely on the idea of cleaning up after themselves. Instead they drop anything they want to get rid of anywhere at any time. Many people, but not all. Some, like myself, still prefer to take their used Kleenex home – just to put it into one of the twenty or so garbage bags waiting on our balcony for the strike to be settled. Thus, I conclude, there are two kinds of citizens: those who have somehow internalized the rules and follow them regardless of what their fellow citizens are currently up to. And those who just do whatever the majority does – with a strong inclination towards the least possible effort.

I have seen that in developers, too. Programmers who seem to do everything right: unit testing, code formatting, continuous integration etc. But only as long as I’m around. Obviously, they don’t see much sense in following the practices. Or they just don’t care. Or they know better than I do. Or they see the futility of all human endeavour. Or whatever. I just don’t know why they are the way they are, and – what’s even more frustrating – most of the time I – as a consultant – fail to have even the slightest long-term effect on these people. Maybe the (what I consider to be) good software development practices depend too much on certain personality traits (like eg. the willingness to take responsibility).

Johannes

Overcoming Tech Boredom

March 14, 2006

Actually, I thought it would be much easier to find a suitable provider for my first blogging attempts. Since my goal is to provide content and not to configure the myriads of layout options and “skins”, I’m somewhat disappointed about the poor current looks of this blog. Is anyone out there willing to help me polish it up?

Anyway, what I’m planning for the next days / weeks to come is a short series on AJAX, i.e. my experiences when trying to make it work for me. Having been a professional software developer for more than 10 years now (mostly in the J2EE realm during the last 6), I am feeling more and more bored when trying to remember yet another API and trying to apply yet another framework and trying to convince clients and colleagues yet another time that automatic testing actually saves money and so on and so on…

AJAX definitely came as a kind of Saviour to help me out of this tech boredom. For the first time in years I got excited about some new technology and the possibilities it seems to offer. That’s why I started my personal voyage into the intricacy of a seemingly simple thing: Asynchronous Javascript and XML. Are you interested in my travelogue? Hang on then…