Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to main content

Copying and Comparing: Problems and Solutions

  • Conference paper
  • First Online:
ECOOP 2000 — Object-Oriented Programming (ECOOP 2000)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1850))

Included in the following conference series:

Abstract

In object oriented programming, it is sometimes necessary to copy objects and to compare them for equality or inequality. We discuss some of the issues involved in copying and comparing objects and we address the problem of generating appropriate copying and comparing operations automatically, a service that is not provided by most object oriented languages and environments. Automatic generation appears to be not only desirable, because hand-coding these methods is mechanical and yet error-prone, but also feasible, because the form of the code is simple and largely predictable.

Some languages and some object models presented in the literature do support generic copying and comparing, typically defining separate “shallow” and “deep” versions of both operations. A close examination of these definitions reveals inadequacies. If the objects involved are simple, copying and comparing them is straightforward. However, there are at least three areas in which insufficient attention has been given to copying and comparing complex objects: (1) values are not distinguished from objects; (2) aggregation is not distinguished from association; and (3) the correct handling of linked structures other than trees is neglected. Solving the third problem requires a mechanism built into the language, such as exists in Eiffel. Building such a mechanism without modifying the language requires a language with sufficient reflexive facilities, such as Smalltalk. Even then, the task is difficult and the result is likely to be insecure.

We show that fully automatic generation of copying and comparing operations is not feasible because compilers and other software tools have access only to the structure of the objects and not to their semantics. Nevertheless, it is possible to provide default methods that do most of the work correctly and can be fine-tuned with a small additional amount of hand-coding.

We include an example that illustrates the application of our proposals to C++. It is based on additional declarations handled by a preprocessor.

On leave from the Department of Computer Science and Information Systems, University of Jyväskylä Jyväskylä, Finland

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Similar content being viewed by others

References

  1. Serge Abiteboul and Jan Van den Bussche. Deep equality revisited. In T.W. Ling, A. O. Mendelzon, and L. Vieille, editors, Deductive and Object-Oriented Databases: Fourth International Conference, DOOD’ 95, Singapore, December 4–7, 1995, Proceedings, number 1013 in LNCS, Berlin and Heidelberg and New York, 1995. Springer-Verlag.

    Google Scholar 

  2. Ken Arnold and James Gosling. The Java Programming Language. Addison-Wesley, second edition, 1998.

    Google Scholar 

  3. Grady Booch, James Rumbaugh, and Ivar Jacobson. The Unified Modeling Language: User Guide. Object Technology. Addison Wesley, 1999.

    Google Scholar 

  4. Peter Grogono. Issues in the design of an object oriented programming language. Structured Programming, 12(1):1–15, January 1991.

    Google Scholar 

  5. Peter Grogono and Patrice Chalin. Copying, sharing, and aliasing. In Colloquium on Object Orientation in Databases and Software Engineering (ACFAS’94), Montreal, Quebec, May 1994.

    Google Scholar 

  6. Peter Grogono and Markku Sakkinen. A view and interface generator for C++. Technical report, Department of Computer Science, Concordia University, November 1999.

    Google Scholar 

  7. Sonya E. Keene. Object-Oriented Programming in COMMON LISP. Addison-Wesley, 1989.

    Google Scholar 

  8. Setrag N. Khoshafian and George P. Copeland. Object identity. In Proc. ACM Conf. on Object-Oriented Programming Systems, Languages and Applications, pages 406–416, September 1986.

    Google Scholar 

  9. Bjørn Kirkerud. Object-Oriented Programming with Simula. Addison Wesley, 1989.

    Google Scholar 

  10. John Lakos. Large-Scale C++ Software Design. Professional Computing Series. Addison-Wesley, 1996.

    Google Scholar 

  11. Wilf LaLonde and John Pugh. Complexity in C++: A Smalltalk perspective. J. Object-Oriented Programming, 8(1):49–56, March/April 1995.

    Google Scholar 

  12. Barbara Liskov, Russell Atkinson, Toby Bloom, Eliot Moss, J. Craig Schaffert, Robert Scheifler, and Alan Snyder. CLU Reference Manual. Number 114 in LNCS. Springer-Verlag, Berlin and Heidelberg and New York, 1981.

    MATH  Google Scholar 

  13. Barbara Liskov and John Guttag. Abstraction and Specification in Program Development. MIT Press, 1986.

    Google Scholar 

  14. Bruce J. MacLennan. Values and objects in programming languages. ACM SIGPLAN Notices, 17(12):70–79, December 1983.

    Google Scholar 

  15. Ole Lehrmann Madsen, Birger Møller-Pedersen, and Kristen Nygaard. Object-Oriented Programming in the BETA Programming Language. ACM Press/Addison Wesley, 1993.

    Google Scholar 

  16. Bertrand Meyer. Eiffel: the Language. Prentice Hall International, 1992.

    Google Scholar 

  17. Bertrand Meyer. Object-oriented Software Construction. Object Oriented Series. Prentice Hall, second edition, 1997.

    Google Scholar 

  18. Scott Meyers. Effective C++. Addison-Wesley, 1992.

    Google Scholar 

  19. Steven P. Reiss. A Practical Introduction to Software Design with C++. Wiley, 1999.

    Google Scholar 

  20. J. Rumbaugh. Controlling propagation of operations using attributes on relations. In N. Meyrowitz, editor, Proc. ACM Conf. on Object-Oriented Programming Systems, Languages and Applications, pages 285–296, September 1988.

    Google Scholar 

  21. Bjarne Stroustrup. The Design and Evolution of C++. Addison-Wesley, 1994.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2000 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Grogono, P., Sakkinen, M. (2000). Copying and Comparing: Problems and Solutions. In: Bertino, E. (eds) ECOOP 2000 — Object-Oriented Programming. ECOOP 2000. Lecture Notes in Computer Science, vol 1850. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45102-1_11

Download citation

  • DOI: https://doi.org/10.1007/3-540-45102-1_11

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-67660-7

  • Online ISBN: 978-3-540-45102-0

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics