[ANSI-Smalltalk] re: array creation syntax
panulogic at gmail.com
Mon Apr 21 08:41:50 BST 2008
Michael Klein wrote:
> I think the brace array syntax encourages the use of arrays
> as ad-hoc object without classes.
I don't think "ad-hoc objects" are bad by definition.
If instead you create a new class, but use that
class only once, that bloats the code unnecessarily
- and makes it harder to browse the class-hierarchy.
It leads to too many classes.
The situation is the same with blocks. You could
say that a block is an ad-hoc method. That doesn't
mean that blocks are bad. You could replace
(the content of) any block with a method-call to self.
But that would lead to too many methods.
Giving a name to something is justified when the
thing named is used in more than one or two places.
If a thing is used only once, giving it a name and
definition would be overhead.
And note that Arrays are Objects too. If they are
"ad-hoc" it means they are created "for a specific
purpose". Nothing wrong with that. Same goes
for Dictionaries. They are ad-hoc too.
More information about the ANSI-Smalltalk