Difference between revisions of "Circle-ellipse problem"
Karl Jones (Talk | contribs) (Created page with "In software development, the '''circle-ellipse problem''' (sometimes termed the square-rectangle problem) illustrates several pitfalls which can arise when using Subtypi...") |
(No difference)
|
Latest revision as of 08:21, 4 September 2016
In software development, the circle-ellipse problem (sometimes termed the square-rectangle problem) illustrates several pitfalls which can arise when using subtype polymorphism in object modelling.
The issues are most commonly encountered when using object-oriented programming (OOP).
Description
By definition, this problem is a violation of the Liskov substitution principle, which occurs in the term single responsibility, open-closed, Liskov substitution, interface segregation and dependency inversion (SOLID).
The problem concerns which subtyping or inheritance relationship should exist between classes which represent circles and ellipses (or, similarly, squares and rectangles).
More generally, the problem illustrates the difficulties which can occur when a base class contains methods which mutate an object in a manner which may invalidate a (stronger) invariant found in a derived class, causing the Liskov substitution principle to be violated.
The existence of the circle-ellipse problem is sometimes used to criticize object-oriented programming. It may also imply that hierarchical taxonomies are difficult to make universal, implying that situational classification systems may be more practical.
See also
- Inheritance (object-oriented programming)
- Liskov substitution principle
- Method (computer programming)
- Object model
- SOLID (object-oriented design)
- Subtyping
External links
- Circle-ellipse problem @ Wikipedia.org