c4s wrote:If a programmer knows how to code properly, sticks to general coding standards and complies with the documented behavior (most important!), this would never happen.
In a perfect world, perhaps. But the reality is that, under the pressure of cost and time constraints, mistakes are made even when standards are upheld.
Inheritance and protected procedures are a Trojan Horse that allows classes to be involved in the inner workings of other classes. Classes are no longer black boxes with public methods. Over time, often with thousands of classes to maintain, conflicts begin to appear in the hierarchy of classes and base classes. And these problems are causing people to question the current concepts of inheritance and protected procedures.
A modified appoach is to create an instance of the base class within a new class, rather than inherit the base class. The new class can make base class methods and properties visible to the outside world by means of its own public methods. This way, the new class and base class are true black boxes that know nothing of the other's inner workings. New features can be added to both without the risk of conflicts to other classes in the hierarchy.
We've been using this technique for a number of years. Nothing is inherited. We still have old applications using new versions of our classes. And although our classes have evolved and become more complex over the years, we've never had problems.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan