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 itself.

Also, in general, programmers should program to interfaces rather than concrete implementations.

Solutions

* Ruby has Mixins and Monkey patching
* Objective-C has Categories
* Component Pascal deprecates Supercalls
* Java allows inheritance to be prohibited by labeling the class declaration with the keyword "final". In the book "Effective Java", author Joshua Bloch writes (in item 17) that programmers should "Design and document for inheritance or else prohibit it".

See also

* Fragile binary interface problem
* Implementation inheritance
* Inheritance semantics
* Software brittleness
* Virtual Inheritance (object-oriented programming)

External links

* [http://www.cas.mcmaster.ca/~emil/publications/fragile/ A Study of The Fragile Base Class Problem] - Scientific description and analysis of the fragile base class problem by Leonid Mikhailov and Emil Sekerinski
* [http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html Why Extends is Evil] - An example in Java
* [http://java.sun.com/docs/books/effective/toc.html Item 17: Design and document for inheritance or else prohibit it]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Fragile Base Class Problem — Das Fragile Base Class Problem (FBC) ist ein Fehlverhalten von Software, das bei der objektorientierten Softwareentwicklung beim Versionswechsel der eingesetzten Basissoftware auftreten kann und mit dem Vererbungsmechanismus zusammenhängt. Es… …   Deutsch Wikipedia

  • Fragile binary interface problem — The fragile binary interface problem or FBI is a shortcoming of certain object oriented language compilers, in which internal changes to an underlying class library can cause descendant libraries or programs to cease working. It is an example of… …   Wikipedia

  • fragile — [ fraʒil ] adj. • 1361; lat. fragilis (→ frêle), de frangere « briser » 1 ♦ Qui se brise, se casse facilement (de par sa nature même). ⇒ cassant. Fragile comme du verre : très fragile. Emballer soigneusement un objet fragile. Attention, c est… …   Encyclopédie Universelle

  • Nelson class battleship — HMS Rodney in Valletta Harbour, Malta during July 1943 Class overview Name: Nelson Operators …   Wikipedia

  • Is-a — Vererbung dargestellt mittels UML. Die abgeleitete Klasse hat die Attribute x und y und verfügt über die Methoden a und b (im UML Sprachgebrauch Operationen a und b). Die Vererbung (engl. Inheritance) ist eines der grundlegenden Konzepte der… …   Deutsch Wikipedia

  • Vererbung (objektorientierte Programmierung) — Vererbung dargestellt mittels UML. Die abgeleitete Klasse hat die Attribute x und y und verfügt über die Methoden a und b (im UML Sprachgebrauch Operationen a und b). Die Vererbung (engl. Inheritance) ist eines der grundlegenden Konzepte der… …   Deutsch Wikipedia

  • Vererbung (Programmierung) — Vererbung dargestellt mittels UML. Die abgeleitete Klasse hat die Attribute x und y und verfügt über die Methoden a und b (im UML Sprachgebrauch Operationen a und b). Die Vererbung (engl. Inheritance) ist eines der grundlegenden Konzepte der… …   Deutsch Wikipedia

  • Self (programming language) — Infobox programming language name = Self paradigm = object oriented prototype based year = 1986 designer = David Ungar, Randall Smith developer = David Ungar, Randall Smith, Stanford University, Sun Microsystems latest release version = 4.3… …   Wikipedia

  • List of object-oriented programming terms — Those words found in object oriented programming. Some are related to OOP and some not. A * Abstract class (also called deferred class) * Abstract method * Abstraction (computer science) * Access control * Accessor method * Allocated class *… …   Wikipedia

  • IBM System Object Model — For the similarly named executable file format in the HP UX operating system, see System Object Model (file format) In computing, the System Object Model (SOM) is an object oriented shared library system developed by IBM. A distributed version… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”