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:

    Now launch the small ship, now as the body dies
    and life departs, launch out, the fragile soul
    in the fragile ship of courage, the ark of faith
    with its store of food and little cooking pans
    and change of clothes,
    —D.H. (David Herbert)

    The base emotions Plato banned
    have left a radio-active and not radiant land.
    Libby Houston (b. 1941)

    People with a culture of poverty suffer much less from repression than we of the middle class suffer and indeed, if I may make the suggestion with due qualification, they often have a hell of a lot more fun than we have.
    Brian Friel (b. 1929)