To appear in Mathematical Foundations of Computer Science 93, LNCS, Springer-Verlag 1 Data Encapsulation and Modularity: Three Views of Inheritance J.F.Costa, A.Sernadas & C.Sernadas INESC & Dept. Matemática - IST Apartado 10105, 1017 Lisboa Codex, PORTUGAL fgc@inesc.pt Abstract . A semantic domain based on state-machines is proposed for object- orientation in order to clarify the most important constructions: aggregation, in- terconnection and specialization. Three kinds of specialization are discussed: sub- typing (specialization without side-effects and no non-monotonic overriding); monotonic specialization (possibly with side-effects but still with monotonic overriding only); and non-monotonic specialization (possibly with side-effects and non-monotonic overriding). 1.Introduction The advantages of the object-oriented approach to software engineering are by now well understood. Many object-oriented languages, systems and methods have been proposed and some of them are now extensively used. To name just a few, there are programming languages like Smalltalk, C ++ and Eiffel, database systems like GemStone, O 2 , IRIS and ORION, development methods like GOOD, MOOD and HOOD, as well as high-level specification languages [Goguen 91, Jungclaus et al 91, SernadasA et al 89]. Moreover, some effort has been dedicated to the theoretical foundations of this promising paradigm. The overview [Ehrich et al 92] points to several schools of thought in this area: e.g. ADT-based like [Goguen 91] and process-based like [Ehrich et al 91]. Higher programmer productivity through software reuse is paramount among the claimed advantages of object orientation. A rich mechanism of inheritance, including both specialization and abstrac- tion, is essential for supporting the envisaged levels of software reuse. Another essential ingredient is a general mechanism for putting objects together, that is, for setting-up communities of interacting objects. Therefore, a semantic foundation of object-orientation should address all these issues: specialization, abstraction and interconnection. Herein, we adopt the view that an object is a state-machine, adapting the notion of reactive system proposed in [Manna and Pnueli 81]. Then, we develop the notion of object morphism in order to explain the basic relationhips between objects: is-a and is-part-of. To this end we apply the program outlined in [Costa et al 92] to objects as state-machines. The advant- ages of the new semantic domain are all related to the abstract view of the state: both the behaviour (process) and the memory structure (slot valuation) of the object appear as secondary concepts on top of the notion of state. By avoiding concrete states we arrive at a cleaner notion of object morphism that makes possible a unified semantic domain explaining all basic relationships between objects. Namely, we explain three kinds of specialization (strict, with side-effects, and with overriding), the part-of relationship between an object and each of its components and two basic kinds of mechanisms for