super super

Norton, Chris chrisn at Kronos.com
Thu Feb 17 22:11:42 UTC 2000


Hi Jan & friends.

Jan Theodore Galkowski wrote:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hmmm....  Let's think about this.  A>>foo, B inherits from A, C inherits
from B.  So, what are the possibilities?  If B doesn't have a foo, as
B>>foo, then A>>foo is already visible to C, as C inherits from B.  If B
_does_ have a foo, then there's  

       A>>foo
         |
       B>>foo
         |
       C>>foo  ??

Looks to me -- and I know you said the thing wasn't refactored -- like C
ought to inherit from A, not B.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Well, sure....  Refactoring is easy when you've got the time and the freedom
to do so (not to mention a simple class hierarchy).  I wouldn't generally
promote the deliberate obfuscation of code through the means of a super
super or some other superclass method redirection scheme.  Clearly, the
right thing to do is to clean up the badly factored code.

However, there are times when you are working on an existing system that is
actually being sold and is thus full of old, fragile, but tested and
predictable code.  When you are given a bug to fix, sometimes it is not
appropriate to refactor your class hierarchy.  In fact, it is often the case
that the directive is:  Just do a quick fix -- we'll re-architect the system
in the next release.

In cases like this, I have been given the unpleasant task of "just making it
work" and this is where I wished I could call super super super super, ad
infinitum.  My solution at the time, was generally to cut and paste the
super..super class method into the subclass and be done with it.  However,
upon reflection, perhaps the right thing to do is to make an object (a Role,
or Action) that models the missing behavior.  For the bug fix, you could
reference the new class and be done.  Then later on, when you are actually
given time to do proper refactoring, you could either clean up your
hierarchy, or create new Actions for the superclass(es) to call.

In general, I agree with everyone's refactoring suggestions.

Refactoring Cheers!

---==> Chris






More information about the Squeak-dev mailing list