MarkingKey

Hans-Martin Mosner hmm at heeg.de
Tue Jun 11 09:20:27 UTC 2002


Niko Schwarz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello,
> 
> In a lot of algorithms it is useful to have a marking key that is bigger than 
> all other elements of a list or another data structure. In other languages 
> you usually use maxInt and so on for that, but that is not appropriate for 
> squeak. I was very surprised that I didn't see any in the class browser -- 
> how come?
Perhaps because it is not so common after all? I'm not aware of an example
for an algorithm which gets significantly simpler by introducing such a thing.
If you can cite an example, please do!

> In fact there really isn't anything, I attached my fix for it.
> 
> Btw, can you help me out? In Java you have getters and setters. In ruby you 
> have ? and plain methods. Whats the counterpart in squeak? I want to two 
> methods that:
> a) set a flag
> b) return the flag.
Then write those methods. Where is the problem?

> 
> I do not want one to toggle the flag, cos for that i have another method.
??? If you don't want a method to toggle the flag, then don't write one.
Whhere is the problem? :-)

> (I find a method called smallest: aBoolean ridiculous. I want two: smallest 
> and biggest, one to write and one to read. How to do that?)
Think about the behavior that you expect, not about method names.
You want two pairs of methods:
beSmallerThanEverythingElse / isSmallerThanEverythingElse
beBiggerThanEverythingElse / isBiggerThanEverythingElse
Right? The first selector tells the object to enter a state,
and the second asks whether it is in that state.
Of course, you could abbreviate them to beSmallest/isSmallest, but that
would lose some of the information connected to the selector.
Your selectors smallest/biggest evoke the image of accessing the biggest/smallest
element in a collection, which is not what you wanted.
Writing methods is really simple, but finding the proper names is not.

Cheers,
Hans-Martin




More information about the Squeak-dev mailing list