A Solution to the Square-Rectangle Problem Within the Framework of Object Morphology
A Solution to the Square-Rectangle Problem Within the Framework of Object Morphology
Author(s): Zbyněk ŠlajchrtSubject(s): ICT Information and Communications Technologies
Published by: Vysoká škola ekonomická v Praze
Keywords: Square-rectangle problem; Circle-ellipse problem; Liskov substitution principle; Object-oriented programming; Object morphology; Scala; Mutable objects
Summary/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.
Journal: Acta Informatica Pragensia
- Issue Year: 5/2016
- Issue No: 1
- Page Range: 34-45
- Page Count: 12
- Language: English