[squeak-dev] message style: few bigs or many littles?

Lauren P drurowin at gmail.com
Fri Apr 1 06:11:17 UTC 2022


Hi List,

The Forth and Lisp upbringing in me is wanting to create more methods that
do fewer things each. So I was curious what seasoned Smalltalkers have to
say. Do you like more littles or fewer bigs?

For those not familiar, in Forth and Lisps function calls are free, so it
makes not a lot of difference if you write 10 1-statement functions that
call the next in line, or 1 10-statement function that does it all, broken
up roughly by the amount you can comprehend without pretty-printing and
commenting.

Here are my thoughts:

Obviously, a reason not to do so is the need to come up with all those
names for "1 method for 1 action", but I use noweb outside of Squeak so
I've gotten pretty good at that.

Another would be a performance penalty of having to do a method lookup more
often.

For pros, the most apparent is making more points where the process can be
inherited and uninherited. Give a name to "check index is a member of the
contents" and a subclass can say "I do this one part faster than my
superclass!" without copy-pasting the entire thing.

You could also use tail calls so you don't waste call stack. I see this
already happens in a few places like PackagePaneBrowser, where
implementation bounces between it and Browser.

For unknowns, there's the director method, which specifies the names of
each step and the order they happen, and the chain method, where each
method specifies what the next step is.

Director is the best method. It offers a clear specification of the steps
that need to happen and offers room for extra steps in between. It also
organizes your thoughts in one place for later reading.

Chain is the best method. It allows a subclass to override the default
specification at an arbitrary point without needing to stub out steps in
the process that aren't applicable. It also doesn't waste methods if you
can short-circuit an operation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220401/7936f6fb/attachment.html>


More information about the Squeak-dev mailing list