Base.js again
Hello, my name is Andrea and I am a code-aholic. I love attacking hard problems, and I enjoy coming up with good solutions to puzzles, and of course I like writing good code. Sylvain wasn’t wrong when he wrote about the feeling writing good code gives you (and sort of implied I am addicted to it): hubris, as Larry Wall would put it, IS one of “The three principal virtues of a programmer”.
I won’t get once again into the reasons why I don’t subscribe to the philosophy that reusing is always better than rewriting, expecially in JavaScript. Instead, I will tell you about how I started using Dean Edward ’s Base.js (see also my previous posts about it) and why there is no contraddiction.
Yes, as strange as it might sound, I actually started converting my current project to use Base.js. The project is exiting the prototyping phase, so I needed to settle down and polish things. In addition, thewhat-happens-if-a-bus-hits-you department was starting to get more and more noisy (and rightly so): my one band has to grow to include at least one guy who could take over should I move to any island with more coconuts than inhabitants.
The conversion has been easy: my code was already partly object-oriented, but I didn’t have any inheritance, so that’s both where I had the most work to do and where the biggest immediate payoff is. My code now is more manageable, more readable and above all, self-explanatory to anybody who knows Base (or who is willing to spend the hour to get to know it).
I haven’t been able to find any downside for now. The library feels very natural, like a small extension to the language, and never gets in the way. I have an issue with inheriting static methods, which isn’t working for me at all; I am posting it to the author’s blog, he is usually very responsive.
So, did I change my mind? No, I didn’t. I am using Base because it does one thing well, in 100 lines of code (including comments and empty lines) in a way that is not intrusive. In fact, the author has another library that provides generic enumeration ; wisely he has decided not to bundle it in Base, but keep it separate.
Comments
Leave a Reply