Old code = Blech!
| Published: | Comments: 1 | Filed under: Development
To gear up or some more challenging tasks, I've been writing specs for Rect. If there's anything to inspire humility in a programmer, it's looking over his own code from 4 years ago. Frankly, Rect is completely embarrassing to look at now.
Rect was one of the first classes I wrote for Rubygame, back in 2004, and aside from a few tweaks, it has remained mostly unchanged since then. Looking over the code now, it's obvious that the "stability" (read: stagnation) of the code is more a testament to my own laziness than to the code's "timeless perfection".
Heck, most of this stuff has no tests at all. I found out just now that Rect#collide_hash and Rect#collide_hash_all have been broken since even before Rubygame 1.0! Somehow, no one noticed that I had typed "collide_rect?+( ... )" instead of "collide_rect?( ... )", which leads me to two conclusions:
- Ruby doesn't like it when you throw in random plus signs where they don't belong.
- No one has ever used those two functions in Rubygame's entire history (or at least never told me they were broken).
Of course, neither of these findings is particularly surprising.
Comments