On Tue, Nov 25, 2008 at 7:19 PM, Greg A. Woods; Planix, Inc. woods@planix.ca wrote:
An object shouldn't have to use accessor methods to get at its own internal state, no matter where in the class hierarchy its state may be defined. "super" is only needed to get around explicit re-definitions done by the subclass.
And thus the fragile superclass problem is born.
The thing is, there are two overlapping but different perspectives here. From an object-centric view, sure, any state or behavior is there in the object and where in the hierarchy it comes from is a minor detail.
However, as far as the code goes, we are talking about distinct chunks of code, potentially written, maintained and updated by different people. A subclass depends on the superclass in the same way that code using a library is a dependent of that library's API. Managing that dependency has maintainability repercussions, and weakening it is a good thing.
Cheers,
--Vassili