Schizophrenia (object-oriented programming)
Encyclopedia
Object schizophrenia or self schizophrenia is a complication arising from delegation
Delegation (programming)
In object-oriented programming, there are two related notions of delegation.* Most commonly, it refers to a programming language feature making use of the method lookup rules for dispatching so-called self-calls as defined by Lieberman in his 1986 paper "Using Prototypical Objects to Implement...

 and related techniques in object-oriented programming.

An object
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...

 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
Delegation (programming)
In object-oriented programming, there are two related notions of delegation.* Most commonly, it refers to a programming language feature making use of the method lookup rules for dispatching so-called self-calls as defined by Lieberman in his 1986 paper "Using Prototypical Objects to Implement...

, which is semantically equivalent. 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 bs 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
Delegation (programming)
In object-oriented programming, there are two related notions of delegation.* Most commonly, it refers to a programming language feature making use of the method lookup rules for dispatching so-called self-calls as defined by Lieberman in his 1986 paper "Using Prototypical Objects to Implement...

, the object has two identities.

By way of metaphor with the public confusion of dissociative identity disorder
Dissociative identity disorder
Dissociative identity disorder is a psychiatric diagnosis and describes a condition in which a person displays multiple distinct identities , each with its own pattern of perceiving and interacting with the environment....

 with the psychiatric diagnosis of schizophrenia
Schizophrenia
Schizophrenia is a mental disorder characterized by a disintegration of thought processes and of emotional responsiveness. It most commonly manifests itself as auditory hallucinations, paranoid or bizarre delusions, or disorganized speech and thinking, and it is accompanied by significant social...

, the former being associated with "split personalities," this configuration is called object schizophrenia or self schizophrenia in object-oriented programming.

History and discussion

Herrmann reports that the term was coined by William Harrison, IBM Research, around May 1997 in a set of web pages, which discussed problems incurred by some of the common Design Patterns
Design Patterns
Design Patterns: Elements of Reusable Object-Oriented Software is a software engineering book describing recurring solutions to common problems in software design. The book's authors are Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides with a foreword by Grady Booch. The authors are...

 (these web pages are no longer publicly available). In the given examples the problem was aggravated by the fact that typical solutions would use a weaker form of delegation
Delegation
Delegation is the assignment of authority and responsibility to another person to carry out specific activities. However the person who delegated the work remains accountable for the outcome of the delegated work. Delegation empowers a subordinate to make decisions, i.e...

 (sometimes called forwarding) where knowledge about the original receiver object is actually lost during delegation
Delegation
Delegation is the assignment of authority and responsibility to another person to carry out specific activities. However the person who delegated the work remains accountable for the outcome of the delegated work. Delegation empowers a subordinate to make decisions, i.e...

. Here the use of forwarding is owed to the fact that most mainstream object-oriented programming languages do not support the stronger form of delegation
Delegation
Delegation is the assignment of authority and responsibility to another person to carry out specific activities. However the person who delegated the work remains accountable for the outcome of the delegated work. Delegation empowers a subordinate to make decisions, i.e...

.
Harrison et al proposed Subject-oriented programming
Subject-oriented programming
In computing, Subject-Oriented Programming is an object-oriented software paradigm in which the state and behavior of objects are not seen as intrinsic to the objects themselves, but are provided by various subjective perceptions of the objects...

 as a solution, which by static composition avoids any issues of object schizophrenia. On the other end of the spectrum, Herrmann shows that a language featuring contextual roles
Role-Oriented Programming
Role-oriented programming is a form of computer programming aimed at expressing things in terms which are analogous to human conceptual understanding of the world. This should make programs easier to understand and maintain....

 can be designed in such a way that potential problems of object schizophrenia are essentially irrelevant despite using delegation
Delegation
Delegation is the assignment of authority and responsibility to another person to carry out specific activities. However the person who delegated the work remains accountable for the outcome of the delegated work. Delegation empowers a subordinate to make decisions, i.e...

as a means to share behavior between a role object and its associated base object.
----
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK