Object-oriented encapsulation for dynamically typed languages

Encapsulation in object-oriented languages has traditionally been based on static type systems. As a consequence, dynamically-typed languages have only limited support for encapsulation. This is surprising, considering that encapsulation is one of the most fundamental and important concepts behind object-oriented programming and that it is essential for writing programs that are maintainable and reliable, and that remain robust as they evolve. In this paper we describe the problems that are caused by insufficient encapsulation mechanisms and then present object-oriented encapsulation, a simple and uniform approach that solves these problems by bringing state of the art encapsulation features to dynamically typed languages. We provide a detailed discussion of our design rationales and compare them and their consequences to the encapsulation approaches used for statically typed languages. We also describe an implementation of object-oriented encapsulation in Smalltalk. Benchmarks of this implementation show that extensive use of object-oriented encapsulation results in a slowdown of less than 15 percent.

[1]  Alan Snyder,et al.  Encapsulation and inheritance in object-oriented programming languages , 1986, OOPLSA '86.

[2]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .

[3]  Craig Chambers,et al.  Parents are shared parts of objects: Inheritance and encapsulation in SELF , 1991, LISP Symb. Comput..

[4]  Liuba Shrira,et al.  Ownership types for object encapsulation , 2003, POPL '03.

[5]  Oscar Nierstrasz,et al.  A Survey of Object-Oriented Concepts , 1989, Object-Oriented Concepts, Databases, and Applications.

[6]  James Noble,et al.  Ownership types for flexible alias protection , 1998, OOPSLA '98.

[7]  John Maloney,et al.  Back to the Future The Story of Squeak, A Practical Smalltalk Written in Itself , 1997 .

[8]  James Noble,et al.  Object ownership for dynamic alias protection , 1999, Proceedings Technology of Object-Oriented Languages and Systems. TOOLS 32.

[9]  Ken Arnold,et al.  The Java Programming Language , 1996 .

[10]  Oscar Nierstrasz,et al.  Traits: Composable Units of Behaviour , 2002, ECOOP.

[11]  Jan Vitek,et al.  Flexible Alias Protection , 1998, ECOOP.

[12]  Mario Wolczko Encapsulation, delegation and inheritance in object-oriented languages , 1992, Softw. Eng. J..

[13]  Kent L. Beck,et al.  Extreme programming explained - embrace change , 1990 .

[14]  Edwin H. Blake,et al.  On Including Part Hierarchies in Object-Oriented Languages with an Implementation in Smalltalk , 1987, ECOOP.

[15]  Luca Cardelli,et al.  On Binary Methods , 1995, Theory Pract. Object Syst..

[16]  John Tang Boyland,et al.  Capabilities for Sharing: A Generalisation of Uniqueness and Read-Only , 2001, ECOOP.

[17]  Michael Barnett,et al.  Friends Need a Bit More: Maintaining Invariants Over Shared State , 2004, MPC.

[18]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[19]  Gilad Bracha,et al.  The programming language jigsaw: mixins, modularity and multiple inheritance , 1992 .

[20]  Kim Mens,et al.  Vrije Universiteit Brussel Faculteit Wetenschappen Reuse Contracts: Managing the Evolution of Reusable Assets Reuse Contracts: Managing the Evolution of Reusable Assets , 2022 .

[21]  Oscar Nierstrasz,et al.  Composable Encapsulation Policies , 2004, ECOOP.

[22]  Craig Chambers,et al.  Alias annotations for program understanding , 2002, OOPSLA '02.

[23]  Richard C. Holt,et al.  The Geneva convention on the treatment of object aliasing , 1992, OOPS.

[24]  James Noble,et al.  Iterators and encapsulation , 2000, Proceedings 33rd International Conference on Technology of Object-Oriented Languages and Systems TOOLS 33.

[25]  John Hogg,et al.  Islands: aliasing protection in object-oriented languages , 1991, OOPSLA '91.

[26]  Paulo Sérgio Almeida Balloon Types: Controlling Sharing of State in Data Types , 1997, ECOOP.

[27]  Dirk Theisen,et al.  JAC—Access right based encapsulation for Java , 2001, Softw. Pract. Exp..