Neha Patil (Editor)

Identity (object oriented programming)

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

An identity in object-oriented programming, object-oriented design and object-oriented analysis describes the property of objects that distinguishes them from other objects. This is closely related to the philosophical concept of identity.

Contents

Consequences of identity

Identity of objects allows objects to be treated as black boxes. The object need not expose its internal structure. It can still be referred to, and its other properties can be accessed via its external behaviour associated with the identity. The identity provides a mechanism for referring to such parts of the object that are not exposed in the interface. Thus, identity is the basis for polymorphism in object-oriented programming.

Identity allows comparison of references. Two references can be compared whether they are equal or not. Due to the identity property, this comparison has special properties. If the comparison of references indicates that the references are equal, then it's clear that the two objects pointed by the references are the same object. If the references do not compare equal, then it's not necessarily guaranteed that the identity of the objects behind those references is different. The object identity of two objects of the same type is the same, if every change to either object is also a change to the other object.

Identity and object-oriented conceptual model

Identity allows the construction of a platonic ideal world, the ontology or conceptual model, that is often used as basis of object-oriented thinking. The conceptual model describes the client side view to a domain, terminology or an API. This world contains point-like objects as instances, properties of the objects and links between those objects. The objects in the world can be grouped to form classes. The properties of the objects can be grouped to form roles. The links can be grouped to form associations. All locations in the world together with the links between the locations form the structure of the world. These groups are types of the corresponding instances of the world.

References

Identity (object-oriented programming) Wikipedia