newbie question

Alan Lovejoy sourcery at pacbell.net
Mon Jul 12 19:54:32 UTC 1999


Ken collins wrote:

>
>  Maybe if I knew ST as well as I'd like, I would have known which non-queer
>  methods to use and not have needed to ask. I didn't find any that did
>  exactly what I wanted, so I started some of my own. I have heard that the
>  best way to learn ST is to just jump in and start coding. How long should I
>  refrain from creating my own methods?
>
>  I apologize for perhaps not knowing the best way to ask my original
>  question. It was really nice to see my code working - except for the failed
>  attempt at this particular method.
>
>  Friends who program in other languages wonder why on earth I am learning
>  ST... I'm not getting paid, my occupation isn't development, language x is
>  the real way to go, etc.
>  ST fascinates me.
>
>  KenC
>

Ken:

Although I think the...advice...the others have given you is correct, 
I also think
that it was...put too strongly.  Please don't feel bad, and please don't stop
experimenting.  Yes, you'll make mistakes, but that's just part of the learning
process.

The best place to add your own stuff when you're doing "real work" is in your
own classes, not in system classes (with some exceptions I'll mention). But
for just playing around, the issue is not as critical.

You may/should/must modify system classes in the following circumstances:

1. Unless you intend to run your code solely as "do its" in a workspace, you
have to modify at least one system method somewhere (to put the startup
code for you application on a system menu, or as part of the image startup
sequence).

2. You have found a bug, and want to fix it.  Beginners would be well advised
to check with experienced Smalltalkers, such as can be found on the Squeak
list, before doing this.

3. You have Smalltalk code from some other non-Squeak implementation
of Smalltalk that you want to port to Squeak, and therefore you need to add
methods/classes that existed in the other implementation's library, but not
in Squeak's.

4. You are an accomplished Smalltalker, and know what you're doing.

5. You are a beginner, and want to play around.  However, in this case,
you must be prepared to accept the probability that your code will not
survive the test of time, it will probably make your system and code
unintelligible to experienced Smalltalkers, and may well cause your
image to crash unrecoverably.

Use common sense.  If you add a #mod12 method to Integer, because
you need integers mod 12, what happens when you or someone else
needs integers mod 10?  mod 2? and so on?  Would it make sense
to have a different #modN message for all N?

And don't think that all the methods in the Squeak system classes all
belong there.  A friend of mine once added the method #isRhinocerous
to Object, purely in protest to what he considered to be a large set
of inappropriate methods in Object.  Heh, #isRhinocerous makes about
as much sense in Object as, say, #isWebBrowser does (which is actually
there!).

If you want to learn how to do things right, it is probably best to adopt
good practices from the beginning.

--Alan




Content-Type: text/x-vcard; charset=us-ascii;
  name="sourcery.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Alan Lovejoy
Content-Disposition: attachment;
  filename="sourcery.vcf"

Attachment converted: Anon:sourcery.vcf 11 (TEXT/R*ch) (0000B0EE)





More information about the Squeak-dev mailing list