Jump to content

Schizophrenia (object-oriented programming)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jcoplien (talk | contribs) at 18:01, 14 June 2010. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Object schizophrenia or self schizophrenia is a complication arising from delegation and related techniques in object-oriented programming.

An object can be defined as a computing concept combining data and behavior, and having an identity. Objects are typically built on class systems. A base class provides the fundamental or default behavior of an object, and acts as a template for creating objects. A derived class can be used to override behaviors of a base class, and can be used as a template for objects whose behaviors refine those of the base class. As an alternative to inheritance — which is a relatively static concept — some programming languages use delegation, which is semantically equivalent.[1] Instead of using one class to refine another, delegation allows one object to override the behavior of another. The original object a (analogous to the base class) can delegate some of its operations to another object b. If a delegates its foo method to the bar method of b, then any invocation of foo on a will cause b's bar method to execute. However, bar executes in the context of the a object — for example, its self identifier refers to a rather than to b.

When delegation is used, the question arises: What is the identity of the object a? The identity is split. There are two potentially meaningful self values when executing a method of a. This problem does not arise in most class-based languages, because an object has a single physical identity. With delegation, the object has two identities.

By way of metaphor with the public confusion of dissociative disorder with the psychiatric diagnosis of schizophrenia in which the self can have several identities, this configuration is called object schizophrenia or self schizophrenia in object-oriented programming.[2]

  1. ^ Lynn Andrea Stein, Delegation is Inheritance. Conference on Object Oriented Programming Systems Languages and Applications, Orlando, Florida, 1987, United States, pp. 138 - 146
  2. ^ Uwe Aßmann, Invasive Software Composition, Springer-Verlag, 2003, p. 39.