[Survey] About the cognitive surcharge of super

Travis Griggs tgriggs at keyww.com
Fri Sep 6 17:31:55 UTC 2002


Stephane Ducasse wrote:
> Hi
> 
> I tried the following test on a lot of people and I was surprised to
> see that so much people got confused.
> 
> I defined the following method on a class
> 
> MyClass>>test1
>         ^ super == self
> 
> MyClass>>test2
>         ^ self class == super class
> 
> 
> then asked MyClass new test1 and MyClass new test2.
> 
> I would like you to try and think as much as you can about the answer.
> Then replied to this email with the results you thought.
> If you do the tests around you please report to me the result you got.

I said true, true. But then I went and wrote the code just to make sure 
I hadn't lost it, and I probably wouldn't have been as willing to report 
back that I hadn't got it right. :)

> 
> Do the test before reading further...
> 
> I found that lot of people were confused by the second test. I have the
> impression that super is cognitively overloaded and should have be be
> called overriden or callNextMethod as in clos.
> For now I got only three good answers including mine :).

Cognitively overloaded... do not know exactly what all that means. I 
think the second method is kind of like subliminal marketting. There's a 
subliminal effect when seeing super class (which in the mind sounds just 
like superclass), to have the first thing that comes to mind be the 
superclass. And we tend to talk about superclasses alot, not sending the 
super version of method class. You could change the name (as in clos), 
but then when somebody writes the code:

call nextMethod

or

callNext method

they're still just as likely to get confused.

One of my favorite about the first example, is that it doesn't 
transmute. I wonder a students answer to the following would be:

"Given

methodA
	^super == self

methodB
	^self == super

Would these return the same result?"

Most students would probably say "well it depends", before they'd 
realize that methodB just won't compile.

-- 
Travis Griggs
Key Technology
10 2 letter words: "If it is to be it is up to me"




More information about the Squeak-dev mailing list