Fragile base class
is a fundamental architectural problem of object-oriented programming systems where base classes (superclasses) are considered "fragile" because seemingly safe modifications to a base class, when inherited by the derived classes, may cause the derived classes to malfunction. The programmer cannot determine whether a base class change is safe simply by examining in isolation the methods of the base class.
Confused overloading
now,
changed to:
and then,
the call to MyMethod(1) that previously correctly called MyMethod(int) in the Base class now calls MyMethod(object) in the Derived class.
Coupling interface and implementation
A class that is design to be inherited from is doing two things: it defines an interface through which any of its subclasses can be used, and it defines an implementation. But it also bundles these two things together into one class. This has a few negative effects:
- Any implementation of that interface is forced to also accept the base class’s implementation.
- The base class’s implementation frequently becomes fragile and difficult to change (more on that in a bit).
- We can no longer have several alternative base implementations on equal footing.
Open recursion
Open recursion is the technical name for how late-binding gets done in classes. When the base class calls another method on itself, expecting to get its own implementation, and gets a subclass implementation instead, that’s the general idea of what open recursion enables.
(fragile base class)
You just want a different implementation of method 2, but keeps the behavior of method1. But now you changed both...