Identity (object-oriented programming)

Identity (object-oriented programming)

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.

Identity and references

A reference can be used to refer to an object with a specific identity. A reference contains the information that is necessary for the identity property to be realized in the programming language, and allows access to the object with the identity. A type of a target of a reference is a role.

Object identity is often not useful, if referential transparency is assumed, because identity is a property that an object may contain, aspects that are not visible in its interface. Thus, objects need to be identified in the interface with a mechanism that is distinct from the methods used to access the object's state in its interface. With referential transparency, the value of the state of the object would be identical or isomorphic with the values accessible from the object's interface. There would be no difference between the object's interface and its implementation, and the identity property would provide no useful additional information.

Identity and location

Identity is closely associated with the location that objects are stored in. Some programming languages implement object identity by using the location of the object in computer memory as the mechanism for realizing object identity. However, objects can move from one place to another without change to their identity, and can be stored in places other than computer memory, so this does not fully characterize object identity.

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.

See also

* Meyer: Object-oriented software construction, second edition


* Domain-driven design: An Entity is defined by identity

Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Identity — may refer to:Philosophy* Identity (philosophy), the sameness of two things * Identity theory of mind, in the philosophy of mind, holds that the mind is identical to the brain * Personal identity (philosophy) * Identity (social science) * Identity …   Wikipedia

  • Object identity — may refer to: Identity (object oriented programming) Equality (objects) This disambiguation page lists articles associated with the same title. If an internal link led you here, you may wish to change the link to point d …   Wikipedia

  • Feature Oriented Programming — (FOP) or Feature Oriented Software Development (FOSD) is a general paradigm for program synthesis in software product lines. FOSD arose out of layer based designs of network protocols and extensible database systems in the late 1980s cite web |… …   Wikipedia

  • Object database — Example of an object oriented model.[1] An object database (also object oriented database management system) is a database management system in which information is represented in the form of objects as used in object oriented programming. Object …   Wikipedia

  • Object-relational impedance mismatch — The object relational impedance mismatch is a set of conceptual and technical difficulties that are often encountered when a relational database management system (RDBMS) is being used by a program written in an object oriented programming… …   Wikipedia

  • Object (computer science) — In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure. (With the later introduction of object oriented programming the same word,… …   Wikipedia

  • Class-based programming — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computin …   Wikipedia

  • C Sharp (programming language) — The correct title of this article is C# (programming language). The substitution or omission of the # sign is because of technical restrictions. C# Paradigm(s) multi paradigm: structured, imperative …   Wikipedia

  • Monad (functional programming) — In functional programming, a monad is a programming structure that represents computations. Monads are a kind of abstract data type constructor that encapsulate program logic instead of data in the domain model. A defined monad allows the… …   Wikipedia

  • Component Object Model — Not to be confused with COM file. Component Object Model (COM) is a binary interface standard for software componentry introduced by Microsoft in 1993. It is used to enable interprocess communication and dynamic object creation in a large range… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”