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:

    My children have taught me things. Things I thought I knew. The most profound wisdom they have given me is a respect for human vulnerability. I have known that people are resilient, but I didn’t appreciate how fragile they are. Until children learn to hide their feelings, you read them in their faces, gestures, and postures. The sheer visibility of shyness, pain, and rejection let me recognize and remember them.
    Shirley Nelson Garner (20th century)

    One does not jump, and spring, and shout hurrah! at hearing one has got a fortune, one begins to consider responsibilities, and to ponder business; on a base of steady satisfaction rise certain grave cares, and we contain ourselves, and brood over our bliss with a solemn brow.
    Charlotte Brontë (1816–1855)

    In verity ... we are the poor. This humanity we would claim for ourselves is the legacy, not only of the Enlightenment, but of the thousands and thousands of European peasants and poor townspeople who came here bringing their humanity and their sufferings with them. It is the absence of a stable upper class that is responsible for much of the vulgarity of the American scene. Should we blush before the visitor for this deficiency?
    Mary McCarthy (1912–1989)