Talk:Call super

From CSSEMediaWiki
Revision as of 03:52, 21 July 2009 by JaninaVoigt (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is done quite commonly and I'm not sure if it's such a bad thing. I can see how it can cause problems, especially if you are subclassing classes that you haven't written yourself or maybe even don't have access to the source for. In that case, it may be hard for you to know whether or not you have to call the overridden method.

However, in a class hierarchy that is all written by the same team of developers I don't really see an issue with requiring a call to the overridden method, as long as this requirement is properly documented.

It is possible that it depends on your view of classes and objects and the encapsulation boundary. If you think in terms of class encapsulation (i.e. the encapsulation boundary is around the class) it makes little sense to require calling an overridden method in another class. However, if you think in terms of object encapsulation, the superclass' data and behavior is an intrinsic part of the final object and it doesn't really seem like a bad thing to have to call another one of your own methods. -- Janina Voigt