Chapter 12. Better Living Through Code Reuse
At one time in my career, I was a consultant, or, if you prefer, a hired gun. My job was to ride into town, clean up things, and then ride off into the sunset. It was like being a Wild West hero, just me and my horsealright, just me and my little blue car. Please believe me when I say that I ride like the late movie star Lee Marvin; have you ever seen Cat Balloo? If you haven't, let's just say that my posture in the saddle isn't the best.
The reason that I bring this up is that, like those heroes of old, I lived by my wits, or approximately half of my wits, and what I could carry with me. However, instead of a Colt Dragoon, I carried a laptop loaded with every little tool I had ever written or downloaded. Some of the tools were useful and some of them were not so useful, but nevertheless, it contained everything that I could possibly need, not counting the games. I suppose another way to look at it is that I'm a packrat, but once I code something, I'd rather not code it again.
Of course, it wasn't that I was avoiding coding; actually, I was avoiding the debugging. The act of debugging isn't distasteful, but the act of debugging the same thing again and again gets old really fast. Ever hear the phrase "don't reinvent the wheel"? Well, I wholeheartedly agree with it. Although, maybe if I could make it better ....
The best part of these Ajax tools is that they aren't carved in stone; they are actually more scribbled in crayon. Because of this, they are fluid, meant to be more of a guide than gospel. However, even if you choose not to use these, I recommend that you at least look at them. Most of these functions work pretty much the same.
The reason is pretty simple. You see, Ajax applications are just like lemonade. In other words, there are a few basic ingredients, as with lemons, sugar, and water. Of course, not all lemonades are created equal. This is mostly because of the amounts of each ingredient and the little extras, such as vodka or checking an object's readyState property.