This Article 
 Bibliographic References 
 Add to: 
Representation Inheritance: A Safe Form of "White Box" Code Inheritance
February 1997 (vol. 23 no. 2)
pp. 83-92

Abstract—There are two approaches to using code inheritance for defining new component implementations in terms of existing implementations. Black box code inheritance allows subclasses to reuse superclass implementations as-is, without direct access to their internals. Alternatively, white box code inheritance allows subclasses to have direct access to superclass implementation details, which may be necessary for the efficiency of some subclass operations and to prevent unnecessary duplication of code.

Unfortunately, white box code inheritance violates the protection that encapsulation affords superclasses, opening up the possibility of a subclass interfering with the correct operation of its superclass' methods. Representation inheritance is proposed as a restricted form of white box code inheritance where subclasses have direct access to superclass implementation details, but are required to respect the representation invariant(s) and abstraction relation(s) of their ancestor(s). This preserves the protection that encapsulation provides, while allowing the freedom of access that component implementers sometimes desire.

[1] B. Liskov and J.M. Wing, ”A Behavioral Notion of Subtyping,” ACM Trans. Programming Languages and Systems, vol. 16, no. 6, pp. 1,811–1,841, Nov. 1994.
[2] S.H. Edwards, "An Approach for Constructing Reusable Software Components in Ada," IDA Paper P-2378, Inst. For Defense Analyses, Alexandria, Virginia, Sept. 1990.
[3] B. Liskov and J. Guttag, Abstraction and Specification in Software Development, MIT Press, Cambridge, Mass., 1986.
[4] P. Bucci, J.E. Hollingsworth, J. Krone, and B.W. Weide, "Implementing Components in RESOLVE," ACM SIGSOFT Software Eng. Notes, vol. 19, pp. 50-52, Oct. 1994.
[5] G.T. Leavens and W.E. Weihl, "Specification and Verification of Object-Oriented Programs Using Supertype Abstraction," Acta Informatica, vol. 32, no. 8, pp. 705-778, 1995.
[6] J.M. Wing, “A Specifier's Introduction to Formal Methods,” IEEE Computer, vol. 23, pp. 8–24, Sept. 1990.
[7] M. Sitaraman, L.R. Welch, and D.E. Harms, "On Specification of Reusable Software Components," Int'l J. Software Eng. and Knowledge Eng., vol. 3, no. 2, pp. 207-229, 1993.
[8] J. Lamping, ”Typing the Specialization Interface,” Proc. Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 201–214, Sept. 1993.
[9] J. Lamping and M. Abadi, "Methods as Assertions," ECOOP'94—Object-Oriented Programming, Proc. Eighth European Conf., Lectures Notes in Computer Science, vol. 821, pp. 60-80.New York: Springer-Verlag, 1994.
[10] R. Stata and J.V. Guttag, ”Modular Reasoning in the Presence of Subclassing,” Proc. Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 200–214, Oct. 1995.
[11] M. Sitaraman and B. Weide, "Component-Based Software Using RESOLVE," ACM Software Eng. Notes, Oct. 1994.
[12] B. Meyer, Reusable Software: The Base Object-Oriented Component Libraries, Prentice Hall, 1994.
[13] B. Meyer,Object-Oriented Software Construction. Englewood Cliffs, NJ: Prentice-Hall, 1988.
[14] J. Hollingsworth, "Software Component Design for Reuse," PhD dissertation, Ohio State Univ., Columbus, 1992.
[15] D.E. Perry and G.E. Kaiser, Adequate Testing and Object-Oriented Programming J. Object-Oriented Programming, vol. 2, no. 5, pp. 13-19, 1990.
[16] E.J. Klimas, S. Skublics, and D.A. Thomas, Smalltalk with Style. Prentice-Hall, 1996.
[17] B.H. Liskov and J.M. Wing, "A New Definition of the Subtype Relation," ECOOP'93—Object-Oriented Programming, Proc. Seventh European Conf, Lecture Notes in Computer Science, vol. 707, pp. 118-141,New York: Springer-Verlag, 1993.
[18] K. Lano and H. Haughton, eds., Object-Oriented Specification Case Studies.Englewood Cliffs, N.J.: Prentice Hall, 1993.
[19] S. Muralidharan and B.W. Weide, "Should Data Abstraction be Violated to Enhance Software Resuse?" Proc. Eighth Ann. Nat'l Conf. Ada Technology,Atlanta, pp. 515-524, ANCOST, Inc., Mar. 1990.

Index Terms:
Abstraction function, abstraction relation, behavioral subtype, inheritance, model-based specification, object-oriented, representation invariant, reuse, specialization, subclass.
Stephen H. Edwards, "Representation Inheritance: A Safe Form of "White Box" Code Inheritance," IEEE Transactions on Software Engineering, vol. 23, no. 2, pp. 83-92, Feb. 1997, doi:10.1109/32.585498
Usage of this product signifies your acceptance of the Terms of Use.