Joao Pedrosa
Posts: 114
Nickname: dewd
Registered: Dec, 2005
|
|
Re: Writing Software is Like ... Writing
|
Posted: Apr 22, 2009 3:31 AM
|
|
It has to be a good analogy, I am told. ;-)
It is strange though in that as we gain experience, we learn to appreciate more of the good things we see even if what we were doing was not going to directly affect the bottom line of the project we were applying ourselves to.
I just fixed a little bug in my code that I wrote a while ago. The bug was not being triggered because of a coincidence that the loop would find the key in the first try so the loop was not necessary for all of the code that depended on it... It was like this, in Javascript:
for(var i = 0; this.gut.rows.length; i++){ if(this.gut.rows[pk]){ return etc; } }
Sure the code was ugly. When I first wrote it I was not as acquainted with JavaScript and I "invented" the "gut design pattern" to hold the "private" data of the object leaving the methods all the namespace they could require in the public part of the class. ;-) That was just a few lines out of thousands of them and I even moved from JavaScript framework to another like from ExtJS, to jQuery and then to Prototype. As a matter of fact, what prompted me to edit these files was another conversion that I was trying to make, to move to the YUI 3 JavaScript library. In the process I found motivation to clean up some of the code, even though I ended up forgoing YUI 3 as my usage of it was not to the letter and I happened into some issues with it, not considering that YUI 3 is still in alpha state, albeit being used by some Yahoo! sites.
Another little story was when a week ago, I was quite excited about running JavaScript on the server-side with the Google JavaScript engine (V8). It allowed me to experiment with JavaScript without being stuck with the browser. I tried to create some OOP example with 3 classes, one inheriting the other, and calling "super()" from the constructors and from a method.
Once I got that working, I had the idea of benchmarking it against Ruby, Python and PHP. I then set to create similar programs in them and in the process I learned some more about inheritance in Python and PHP. As a curiosity, the benchmark showed JavaScript being over 10 times faster at that benchmark, and upon reading the design behind Google's V8, I could understand that they have further optimized things like properties and even compile JavaScript to machine code!
With all of that said, one more thing that surprises me is when I see lots of old code that I wrote and think "how did I do that?"
And as most of you know, once a program is written, it can run indefinitely, which is the biggest wonder of programming, if I may say so.
That and being able to write, however non-native English speaking one is. ;-)
Cheers.
|
|