[MERGE] test framework distinguishes skips

Aaron Bentley aaron.bentley at utoronto.ca
Sun Jul 9 04:34:53 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Pool wrote:

>> When subclassing, I find I'm often faced with the decision of whether to
>> supplement the base class method or override it.  Using super seems to
>> make that decision almost impossible.  What if the called method throws
>> NotImplemented?
> 
> Part of the class's contract is whether and how it can be subclassed or
> extended.

That is fine if I know what class I'm calling methods on.  But if there
is multiple-inheritance, then using super means I don't know what class
I'm calling, so I don't know what its contract is.

> There's also an inverted control pattern where the subclass will provide
> the "real" implementation, but the superclass needs control of it.  So
> here we tend to have a protected method which is only called by the
> superclass, and the method that calls it should not be overridden.

e.g. the Config object?

> To sum up: the base class should tell you what to do and if it does not,
> it's a bug.

It's not the base class I'm worried about.  Consider this inheritance

       Parent
        / \
   ChildA ChildB
        \ /
    GrandChild

In this situation, ChildB will call methods on ChildA, not on Parent,
event though ChildB knows nothing about ChildA.

>> Additionally, since it's possible that the method called by super will
>> have different parameters, it seems like self, *args and **kwargs are
>> the only safe parameters for a method that invokes super, and using
>> those exclusively seems like a great loss.
> 
> In our code we should always know which method will actually end up
> being called, and so what parameters it will take.  Then the choice of
> 
>   super(SomeSubclass, self).method()
> 
> vs
> 
>   SuperClass.method(self)
> 
> just comes down to relative clarity, vs not repeating the superclass
> name.

This is only true if we don't have multiple inheritance.  Are you saying
we should avoid multiple inheritance?

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEsHlc0F+nu1YWqI0RArzIAJ93aoWo39U7VZFLftJ5P9sGAMeqTACdFtVu
Pgf1PCogPWIoaBMyMlvuzO4=
=K8xs
-----END PGP SIGNATURE-----




More information about the bazaar mailing list