super super

agree at carltonfields.com agree at carltonfields.com
Thu Feb 17 22:33:26 UTC 2000


> Well, sure....  Refactoring is easy when you've got the time > and the freedom
> to do so (not to mention a simple class hierarchy).

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

You certainly don't need to mess with the language to accomplish a hack, particularly when you have conciously decided to do a hack!  In you example:

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

All you have to do is code

	B>>classAFoo
		"Hack to obtain access to A>>foo from subclasses"
		^super foo

	and then code

	A>>foo
		. . .
		super classAFoo.
		. . .

which has the virtue of making it clear to the world that it is a hack.  (Of course, there are many other ways to obtain the same result, each introducing some subtle and not-so-subtle fragility to the class structure)The alternative

	A>>foo
		. . .
		super super foo.
		. . .

might go entirely without notice until someone DOES have time to do a refactoring and inserts some classes inbetween A, B and C.  All of a sudden, you aren't getting the intended result and you have some subtle bugs to hunt down.

Indeed, Squeak's printOut function had a subtle bug deriving from such a fragility that precluded it from generating proper HTML.  I doubt I would ever have found the bug if the "super super" means were used instead.





More information about the Squeak-dev mailing list