Form>>printOn:
William O. Dargel
wDargel at shoshana.com
Thu Feb 18 22:36:18 UTC 1999
sqrmax at cvtci.com.ar wrote:
> Would you guys mind if the printOn: for Form was something like this?
>
> printOn: aStream
>
> aStream nextPutAll: 'Form('.
> width printOn: aStream.
> aStream nextPut: $x.
> height printOn: aStream.
> aStream nextPut: $x.
> depth printOn: aStream.
> aStream nextPut: $)
>
> Andres.
Personally, I always like printStrings that help distinguish one instance
from another. There's nothing quite like looking at a collection and
seeing (a Form a Form a Form a Form a Form ...).
I'd at least make the following changes to your method though:
aStream
nextPutAll: self class name;
nextPut: $(;
print: width;
nextPut: $x;
print: height;
nextPut: $x;
print: depth;
nextPut: $).
By using "self class name" rather than hardcoding 'Form(' it works nicely
for subclasses like ColorForm, etc. I also prefer using "print:" and a
cascade for things like this (at least since I learned about it ;-). It
makes it easier IMHO to read the sequence of things being assembled for
the printString.
-------------------------------------------
Bill Dargel wdargel at shoshana.com
Shoshana Technologies
100 West Joy Road, Ann Arbor, MI 48105 USA
More information about the Squeak-dev
mailing list
|