Squeak programming question

Carl Watts Carl at AppliedThought.com
Tue Mar 23 17:54:46 UTC 1999


>Quick programming question from a Squeak/Smalltalk newbie:
>Is there any elegant method for handling occasions when you
>wish a method to return multiple objects?  I'm writing a
>method that will return a set and a dictionary to the
>caller.  I can't reasonably break up the method into two
>methods (one for each kind of data), and the contents of
>the set and dictionary are unrelated enough that it seems
>silly to make a whole new class of object containing nothing
>but pointers to each.

Many people have already answered this question with ways to do it.  But given that you are a newbie, I'd like to urge you to consider closely the replies of Markus, Andres, Allen Wirfs-Brock, and others.  Like them I've noticed that almost all the time I hear this question from a newbie, they are missing a valuable opportunity for a new object that is a valuable abstraction (you will thank yourself latter).  So as Allen said:

....if you've reached the point where you need to
communicate some sort of heterogeneous aggregation then its time to define
a new class of object. It may seem like a heavyweight approach but down
stream you will most likely be glad you used a new class. Maintainers of
your code will certainly appreciate it.





More information about the Squeak-dev mailing list