. .


Smalltalk Sort Functions

December 15, 2010 10:43:33.000

Travis has been thinking about sort functions in Smalltalk, and how to follow the same patterns shown in SymbolValue and Block culling:

Since the introduction of SymbolValue and Block culling, one of the things I've chased is how to do this same style of programming with sorting. For most sorting cases, you have a series of objects that you want to sort on some particular attribute. Maybe a sequence of customers you'd like to sort by name.

Travis goes into the approach he picked - go read the whole thing for the details. I do like this summation:

I sat down last night, and with tests, put together a TAG-SortFunctions package, published in the Cincom Public Repository. The basic idea was to use an object. Time and time and time again over the years, I rediscover the principle "there's an object waiting to be birthed here!"

A lot of sins in Smalltalk code can be solved by remembering to create a new object when it's useful to do so. It's not like they cost money :)

Technorati Tags: ,

posted by James Robertson


Re: Smalltalk Sort Functions

[anonymous] December 15, 2010 12:54:45.442

Your final paragraph is worth beating people about the head with. I'm dealing with class hierarchy right now where various authors do horrible things with substrings of strings. Had they built objects using those strings instead, the code could have been much, much cleaner and far more robust.

 Share Tweet This