Delegation by object composition

Class inheritance and method overriding, as provided by standard class-based languages, are often not flexible enough to represent objects with some dynamic behavior. In this respect, object composition equipped with different forms of method body lookup is often advocated as a more flexible alternative to class inheritance since it takes place at run time, thus permitting the behavior of objects to be specialized dynamically. In this paper, we illustrate Incomplete Featherweight Java (IFJ), an extension of Featherweight Java with a novel linguistic construct, the incomplete object. Incomplete objects require some missing methods which can be provided at run time by composition with another (complete) object. Furthermore, we present two mechanisms for the method body lookup on (composed) objects, one based on delegation and the other based on consultation. Thanks to the design of the language, the consultation-based lookup is a simple extension of the delegation-based one. Both mechanisms are disciplined by static typing, therefore the language enjoys type safety (which implies no ''message-not-understood'' run-time errors) and avoids possible accidental overrides due to method name clashes.

[1]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[2]  Stephan Herrmann,et al.  A precise model for contextual roles: The programming language ObjectTeams/Java , 2007, Appl. Ontology.

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

[4]  John Viega,et al.  Automated Delegation is a Viable Alternative to Multiple Inheritance in Class Based Languages , 1998 .

[5]  Arthur J. Riel,et al.  Object-Oriented Design Heuristics , 1996 .

[6]  Kim B. Bruce Foundations of object-oriented languages - types and semantics , 2002 .

[7]  Craig Chambers,et al.  Object-Oriented Multi-Methods in Cecil , 1992, ECOOP.

[8]  Friedrich Steimann,et al.  On the representation of roles in object-oriented and conceptual modelling , 2000, Data Knowl. Eng..

[9]  Silvia Likavec,et al.  Safe and Flexible Objects with Subtyping , 2005, J. Object Technol..

[10]  Adele Goldberg,et al.  SmallTalk 80: The Language , 1989 .

[11]  Martín Abadi,et al.  A Theory of Objects , 1996, Monographs in Computer Science.

[12]  Viviana Bono,et al.  Subtyping-Inheritance Conflicts: The Mobile Mixin Case , 2004, IFIP TCS.

[13]  Viviana Bono,et al.  Type safe dynamic object delegation in class-based languages , 2008, PPPJ '08.

[14]  Philip Wadler,et al.  Featherweight Java: a minimal core calculus for Java and GJ , 1999, OOPSLA '99.

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

[16]  Erik Ernst,et al.  Optimizing Dynamic Class Composition in a Statically Typed Language , 2008, TOOLS.

[17]  Günter Kniesel Type-Safe Delegation for Run-Time Component Adaptation , 1999, ECOOP.

[18]  Elena Giachino,et al.  Featherweight Wrap Java: wrapping objects and methods , 2008, J. Object Technol..

[19]  Sophia Drossopoulou,et al.  Can addresses be types? (A case study: objects with delegation) , 2003, Electron. Notes Theor. Comput. Sci..

[20]  Giuseppe Castagna,et al.  Object-Oriented Programming A Unified Foundation , 1997, Progress in Theoretical Computer Science.

[21]  John C. Mitchell,et al.  A Delegation-based Object Calculus with Subtying , 1995, FCT.

[22]  Oscar Nierstrasz,et al.  Traits: A mechanism for fine-grained reuse , 2006, TOPL.

[23]  Guido Boella,et al.  Interaction between Objects in powerJava , 2007, J. Object Technol..

[24]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

[25]  Viviana Bono,et al.  Object Incompleteness and Dynamic Composition in Java-Like Languages , 2008, TOOLS.

[26]  D. Janaki Ram,et al.  Method driven model: a unified model for an object composition language , 2004, SIGP.

[27]  Henry Lieberman,et al.  Using prototypical objects to implement shared behavior in object-oriented systems , 1986, OOPLSA '86.

[28]  Stephen Kochan Programming in Objective-C 2.0 , 2009 .

[29]  Kasper Østerbye,et al.  Roles: Conceptual Abstraction Theory and Practical Language Issues , 1996, Theory and Practice of Object Systems.

[30]  Viviana Bono,et al.  I-Java: An Extension of Java with Incomplete Objects and Object Composition , 2009, SC@TOOLS.

[31]  John C. Mitchell,et al.  A lambda calculus of objects and method specialization , 1993, [1993] Proceedings Eighth Annual IEEE Symposium on Logic in Computer Science.

[32]  Chitra Babu,et al.  DynOCoLa : Enabling Dynamic Composition of Object Behaviour , .

[33]  Jon G. Riecke,et al.  Privacy via Subsumption , 2002, Inf. Comput..

[34]  Antero Taivalsaari,et al.  On the notion of inheritance , 1996, CSUR.

[35]  Erik Ernst gbeta - a Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance , 2000 .

[36]  Michele Bugliesi,et al.  A Subtyping for Extensible, Incomplete Objects , 1999, Fundam. Informaticae.

[37]  Randall B. Smith,et al.  Self: The power of simplicity , 1987, OOPSLA 1987.