I've figured out why I'm not a world-famous open-source programmer. It's simple, really; I don't have many itches to scratch. Most of the software I have with me pretty much does what I need it to do.
I write software when my aesthetic sensibility is offended. And I have much to be offended about this week. I've been deep inside the guts of FireWatir this week, the web application testing framework written in Ruby, and I have come to the conclusion that the FireWatir programmers have at best a passing familiarity with Ruby and Javascript.
I even showed the FireWatir code that offended me to a co-worker, a programmer of phenomenal youth and skill (I'm the one with age & treachery), and he agreed that the code was offensive. Six hundred lines of the same three lines repeated over and over, each with eight lines of comments above it. Those three lines defined subclasses of Element, for individual HTML components like divs, spans, and paragraphs.
I replaced the whole mess with one four-line function, a one-line list of names, and a one-line call to generate classobjects from the function for each name on the list. My list is more complete than theirs.
In another example, their code builds this humungous raw chunk of javascript, which it then uploads to the JSSH JVM, executes, takes the return value, and then... does nothing. The variables defined and described live for the duration of the test, even though they're never re-used. The builder does this component by component, intermingling ruby and javascript in a mangled heapin' mess of unreadability.
I wrote the lookup function in pure javascript, using a BSD-licensed function findElementsBySelector. When the program starts talking to the JSSH JVM, it uploads and instantiates a single new object, _firewater, which has a reference cache and a collection of functions, including the selector function. All of that huge, ugly ruby/javascript now devolves to this:
(Oh, that's another thing; the idiom 'send this, then read the response' is everywhere in this damned code. You'd think after the third time they'd have boiled it down to a single command. And my command function is smart enough to append the semicolon if you forget!)
See? I'm offended. It must be fixed.
I write software when my aesthetic sensibility is offended. And I have much to be offended about this week. I've been deep inside the guts of FireWatir this week, the web application testing framework written in Ruby, and I have come to the conclusion that the FireWatir programmers have at best a passing familiarity with Ruby and Javascript.
I even showed the FireWatir code that offended me to a co-worker, a programmer of phenomenal youth and skill (I'm the one with age & treachery), and he agreed that the code was offensive. Six hundred lines of the same three lines repeated over and over, each with eight lines of comments above it. Those three lines defined subclasses of Element, for individual HTML components like divs, spans, and paragraphs.
I replaced the whole mess with one four-line function, a one-line list of names, and a one-line call to generate classobjects from the function for each name on the list. My list is more complete than theirs.
In another example, their code builds this humungous raw chunk of javascript, which it then uploads to the JSSH JVM, executes, takes the return value, and then... does nothing. The variables defined and described live for the duration of the test, even though they're never re-used. The builder does this component by component, intermingling ruby and javascript in a mangled heapin' mess of unreadability.
I wrote the lookup function in pure javascript, using a BSD-licensed function findElementsBySelector. When the program starts talking to the JSSH JVM, it uploads and instantiates a single new object, _firewater, which has a reference cache and a collection of functions, including the selector function. All of that huge, ugly ruby/javascript now devolves to this:
oblist = self.command('_whiskey.locate("%s", "%s");' % (selector, self.element_object()))(Oh, that's another thing; the idiom 'send this, then read the response' is everywhere in this damned code. You'd think after the third time they'd have boiled it down to a single command. And my command function is smart enough to append the semicolon if you forget!)
See? I'm offended. It must be fixed.
no subject
Date: 2008-08-28 04:10 pm (UTC)I've done a few tricky things with MS-DOS batch files, written some very simple utilities with Turbo Pascal to work with such stuff.
But even I know that there are better ways of handling repetition than those clowns used. It's the same with art: you don't have to be able to paint the picture to recognise ugly.
no subject
Date: 2008-08-28 04:20 pm (UTC)These guys are clearly at the limit of their cleverness.
no subject
Date: 2008-08-28 04:53 pm (UTC)Please. Scratch away, kind sir, this stuff needs *fixing*.
no subject
Date: 2008-08-28 05:04 pm (UTC)no subject
Date: 2008-08-28 05:08 pm (UTC)no subject
Date: 2008-08-28 10:03 pm (UTC)I tend to be skeptical of criticisms such as the latter, but in this case, it sounds like it's justified. Hell, I'm putting more effort into avoiding duplications in my _tests_ than that! (And Ruby makes it easy to do, too, even though many of these tests are perl-written-in-ruby from when I first started learning it)
no subject
Date: 2008-08-28 06:17 pm (UTC)no subject
Date: 2008-08-29 05:06 am (UTC)no subject
Date: 2008-08-29 07:07 am (UTC)