Identity (object-oriented Programming) - Consequences of 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.

Read more about this topic:  Identity (object-oriented Programming)

Famous quotes containing the words consequences of, consequences and/or identity:

    We are still barely conscious of how harmful it is to treat children in a degrading manner. Treating them with respect and recognizing the consequences of their being humiliated are by no means intellectual matters; otherwise, their importance would long since have been generally recognized.
    Alice Miller (20th century)

    The horror of Gandhi’s murder lies not in the political motives behind it or in its consequences for Indian policy or for the future of non-violence; the horror lies simply in the fact that any man could look into the face of this extraordinary person and deliberately pull a trigger.
    Mary McCarthy (1912–1989)

    No other group in America has so had their identity socialized out of existence as have black women.... When black people are talked about the focus tends to be on black men; and when women are talked about the focus tends to be on white women.
    bell hooks (b. c. 1955)