A Solution to the Square-Rectangle Problem Within the Framework of Object Morphology

Zbyněk Šlajchrt

A Solution to the Square-Rectangle Problem Within the Framework of Object Morphology

Číslo: 1/2016
Periodikum: Acta Informatica Pragensia
DOI: 10.18267/j.aip.83

Klíčová slova: Square-rectangle problem, Circle-ellipse problem, Liskov substitution principle, Object-oriented programming, Object morphology, Scala, Mutable objects, objektově orientované programování, morfologie objektů, Scala, hmatatelné objekty.

Pro získání musíte mít účet v Citace PRO.

Přečíst po přihlášení

Anotace: The square-rectangle problem is often cited as an illustration of pitfalls arising when using object-oriented programming (OOP). A number of solutions have been proposed, however, according to the author, none of them solve the problem satisfactorily, mainly because they tackle the problem from within the current OOP paradigm. This paper presents another solution stemming from object morphology (OM), a new object-oriented paradigm developed to model mutable phenomena. In the framework of OM the problem can be solved directly under the basic OM principle that an object may mutate not only with regard to its state, but also with regard to its type. The main contrast between the presented and the other solutions is that constraint violations caused by changes in an object’s state are no longer necessarily considered errors; instead, they may be interpreted as triggers initiating a mutation of the object’s type. The solution is demonstrated using Morpheus, a proof-of-concept implementation of OM in Scala.