Thursday, June 16, 2011

Smalltalk Extensions

In a previous lifetime I worked for a Smalltalk vendor and my last two posts (here and here) got me thinking about all of the ways that you could hack the Smalltalk environment. In Smalltalk, except for a few primitives, all of the base libraries source code is present and editable in your environment. You can edit the default implementations or easily add additional functionality to base classes. This can lead to all sorts of interesting side effects.

I remember working with one customer that had occasional lock-ups in their development environment which they were blaming on us. These lock-ups were intermittent and hard to reproduce. Well one day while in their environment I was able debug right after a lock-up. I started stepping through some code in the base collection class that I didn't recognize. Turns out they had overridden the inherited Sort function and implemented their own (might have been a quicksort I can't remember) along with a very subtle bug. Given the right list size and starting conditions the code would enter an infinite loop. Fixing their sort function fixed their lock-ups and contributed to my reluctance to ever touch base libraries.


chaetal said...

Write unit tests!

Brad said...

Good unit tests would have saved much frustration.