Temporary variables

Michael S. Klein mklein at alumni.caltech.edu
Fri Jun 18 16:52:45 UTC 1999


It's not just a question of instVars good, tempVars bad.
It's an issue of design.  Earlier, somebody mentioned the 7 +- 2
undifferentiated items that people can mentally juggle.

Once you've got too many of anything, you should start looking for patterns
and abstractions to factor out.  30 tempVars, 30 instVars, 30 globalVars,
30 methods, 30 subclasses, even 30 letters, 30 friends, 30 tasks on my
to do list.

There may be 88 keys on a piano, but I certainly find it helpful to chunk
them into groups of 12.

--

On the otherhand, there is a mental overhead to defining a method.
How is it going to affect the system?  Am I overwriting an existing method?
Will this method be inhereted, unbeknowst to a subclass? Where does the
source go? Etc...

Because of this, it is nice to do quick hacks in a workspace.
So we use temporary variable a lot more in "throw-away" examples,
than actual production code.  Analyses of existing methods do not reflect 
this.

-- Mike

mklein at alumni.caltech.edu





More information about the Squeak-dev mailing list