Object Schizophrenia

From Wikipedia, the free encyclopedia

at http://en.wikipedia.org/wiki/Schizophrenia_(object-oriented_programming) [a URL that this Wiki can't parse correctly]

"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 behaviors) can delegate some of its methods to another object b (analogous to the derived class behaviors). 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 identity disorder with the psychiatric diagnosis of schizophrenia, the former being associated with "split personalities," this configuration is called object schizophrenia or self schizophrenia in object-oriented programming."


I accuse classes/objects of having a Multiple Personality Disorder when I find that they have too much unrelated functionality combined in them. The cure is refactoring. -- JeffGrigg


EditText of this page (last edited December 5, 2010) or FindPage with title or text search