A Solution to the Square-Rectangle Problem Within the Framework of Object Morphology
Zbyněk Šlajchrt
Acta Informatica Pragensia, 2016, vol. 2016, issue 1, 34-45
Abstract:
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.
Keywords: Square-rectangle problem; Circle-ellipse problem; Liskov substitution principle; Object-oriented programming; Object morphology; Scala; Mutable objects (search for similar items in EconPapers)
Date: 2016
References: View complete reference list from CitEc
Citations:
Downloads: (external link)
http://aip.vse.cz/doi/10.18267/j.aip.83.html (text/html)
http://aip.vse.cz/doi/10.18267/j.aip.83.pdf (application/pdf)
free of charge
Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.
Export reference: BibTeX
RIS (EndNote, ProCite, RefMan)
HTML/Text
Persistent link: https://EconPapers.repec.org/RePEc:prg:jnlaip:v:2016:y:2016:i:1:id:83:p:34-45
Ordering information: This journal article can be ordered from
Redakce Acta Informatica Pragensia, Katedra systémové analýzy, Vysoká škola ekonomická v Praze, nám. W. Churchilla 4, 130 67 Praha 3
http://aip.vse.cz
DOI: 10.18267/j.aip.83
Access Statistics for this article
Acta Informatica Pragensia is currently edited by Editorial Office
More articles in Acta Informatica Pragensia from Prague University of Economics and Business Contact information at EDIRC.
Bibliographic data for series maintained by Stanislav Vojir ().