My Stuff
My Amps

Add this feed to a running copy of BottomFeeder

Linux World 2006 Speaker

Wednesday, October 08, 2003

My Prototypical Journey

I've been thinking of little JavaScript programs to do at work. One of these programs parses excel spreadsheets into something that we can easily populate our reference database with. These spreadsheets are what we get from our customers (they use excel for everything). It was cool this morning when they forgot a good chunk of data and they thought it was going to be a big deal because they thought we hand coded what was in the spreadhseet. Now, this is the way developers did it in the past, but I just can't stand that much typing. Anyway, it was nice to have automated the data in the spreadsheet. If truth be told, it took less time to automate it than type in all of the boring stuff in (there was a LOT). The data is also more reliable (if there's errors, we can easily verify via the excel spreadsheet...crap in=crap out). Automation is alwaysa good thing so, I thought it would be neat to see if I could write a test script that drive our application as well. I had a bug that was deep in the application and was tired of starting over from scratch to get to it. So, off I went. I have been becoming quite good at Microsoft's COM/ActiveX technologies, so that part was easy. Anyway, I was amazed how easy it was and why I didn't do it sooner! It worked like a charm! I also realize that I could have done it equally as well in Dolphin ST or Ruby with their COM libraries, but I've been trying to get my head around the "prototypical" way. So, I'm coding my test and I usually start out creating my constructor and then adding methods to my prototype. I kept treating prototypes like you would classes in other languages. I was starting to forward a lot of calls to another object that I was wrapping when I had my "EUREKA!"(tm) moment. I could create an instance of the object I was wrapping and use it as the prototype to the other object. I stopped thinking of terms of class structure but object structure. So, I got rid of a lot of forwarding calls by specializing an instance. I know this is a small step (some might even go how is this different from inheritance? Trust me, it's different in my mind). I'm seeing instances and specialization of specific instances and not just at a class level. I think specialization might work better at this level. Pretty cool stuff. I still have a long way to go before I'm comfortable with it (I generally use composition and not inheritance in class based systems). But, I'm starting to see the light and why so many people like prototypical languages. This morning's "Eureka!"(tm) moment felt like when I got objects in Smalltalk or when I saw the reason for macros in Lisp. Just thought I'd share...


Metalheads Against Racism

This page is powered by Blogger. Isn't yours?