Fragile Base Class

Fragile Base Class

The fragile base class problem 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.

One possible solution is to make instance variables private to their defining class and force subclasses to use accessors to modify superclass states. A language could also make it so that subclasses can control which inherited methods are exposed publicly. These changes prevent subclasses from relying on implementation details of superclasses and allow subclasses to expose only those superclass methods that are applicable to themselves.

Another alternative solution could be to have an interface instead of superclass.

Read more about Fragile Base Class:  Solutions

Famous quotes containing the words fragile, base and/or class:

    lady through whose profound and fragile lips
    the sweet small clumsy feet of April came

    into the ragged meadow of my soul.
    —E.E. (Edward Estlin)

    You see how this House of Commons has begun to verify all the ill prophecies that were made of it—low, vulgar, meddling with everything, assuming universal competency, and flattering every base passion—and sneering at everything noble refined and truly national. The direct tyranny will come on by and by, after it shall have gratified the multitude with the spoil and ruin of the old institutions of the land.
    Samuel Taylor Coleridge (1772–1834)

    We are the party of all labor.
    The whole earth shall be ours to share
    And every race and craft our neighbor.
    No idle class shall linger there
    Like vultures on the wealth we render
    From field and factory, mill and mine.
    Tomorrow’s sun will rise in splendor
    And light us till the end of time.
    Eugène Pottier (1816–1887)