CLU reference manual
Abstraction and specification in program development
Abstraction and specification in program development
OOPLSA '86 Conference proceedings on Object-oriented programming systems, languages and applications
A programmer's guide to object-oriented programming in Common LISP
A programmer's guide to object-oriented programming in Common LISP
Controlling propagation of operations using attributes on relations
OOPSLA '88 Conference proceedings on Object-oriented programming systems, languages and applications
Eiffel: the language
The design and evolution of C++
The design and evolution of C++
Object-oriented programming in the BETA programming language
Object-oriented programming in the BETA programming language
Large-scale C++ software design
Large-scale C++ software design
Object-oriented software construction (2nd ed.)
Object-oriented software construction (2nd ed.)
A practical introduction to software design with C++
A practical introduction to software design with C++
The Unified Modeling Language user guide
The Unified Modeling Language user guide
The Java programming language (2nd ed.)
The Java programming language (2nd ed.)
Object-Oriented Programming with SIMULA
Object-Oriented Programming with SIMULA
DOOD '95 Proceedings of the Fourth International Conference on Deductive and Object-Oriented Databases
Values and objects in programming languages
ACM SIGPLAN Notices
Sealing, Encapsulation, and Mutability
ECOOP '01 Proceedings of the 15th European Conference on Object-Oriented Programming
Dynamic Replacement of Active Objects in the Gilgul Programming Language
CD '02 Proceedings of the IFIP/ACM Working Conference on Component Deployment
JEqualityGen: generating equality and hashing methods
GPCE '10 Proceedings of the ninth international conference on Generative programming and component engineering
Understanding the impact of collection contracts on design
TOOLS'10 Proceedings of the 48th international conference on Objects, models, components, patterns
Proceedings of the ACM international conference companion on Object oriented programming systems languages and applications companion
CBSE'06 Proceedings of the 9th international conference on Component-Based Software Engineering
Hi-index | 0.00 |
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.