newbie question

Peter Smet peter.smet at flinders.edu.au
Tue Jul 13 00:23:31 UTC 1999


>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.


Agreed completely - I think diving in and making mistakes is the way to
learn. I think reading someone else's code is the worst way to learn. For
all those giving advice like: 'read what's in the image', how many of those
actually learned Smalltalk that way? I tried this and found it next to
useless. Until you get a firm grounding via tutorials and examples, reading
the base classes makes no sense. Even if I have someone else's code, I learn
by attempting to formulate my own algorithm, and scrawling some pseudocode.
The funny thing about this approach is, it really works. It makes your mind
more receptive to the problems the original author faced and solved, and it
helps me understand the new code quicker.

>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?


Except that when you look in the collection classes, there really are
methods like first, second, third and fourth..... Where do we stop?
sevenhundredandone?

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


Put the method where it fits best. I get warning bells when I write code
like:
aMessage args do this. aMessage args do that.
I have found in cases where you have to keep extracting parameters in this
fashion that I am probably writing the method in the wrong class. In the
above example, I put the method in Message, and things were immediately much
shorter and cleaner (whenever your code gets smaller you have probably done
something right).

Smalltalk, unfortunately, is so different from other languages that you will
likely find it a major hurdle to learn. I hope you persist, because you will
eventually find yourself solving problems faster and easier than you ever
have. I have found that every language 'gets in the way' when you program.
What I love about Smalltalk is that it is the most unobtrusive language I
have worked with in this regard.

Anyway, keep the group posted about how you fare - we are more than willing
to help.

Peter





More information about the Squeak-dev mailing list