Darwin Project

The Darwin Project

Darwin Project

Home
Delegation
Project
Compiler
Downloads
History
Papers
People
Contact

What is (Not) Delegation

The term delegation originally introduced by Henry Lieberman and implemented in prototype-based languages like Self, is often used in literature to denote another concept, which we prefer to call consultation. The similarities and differences are explained in the folowing and illustrated in figure 1 and figure 2.

 

Similarities

In both cases an object, called the child, may have modifiable references to other objects, called its parents. Messages that cannot be executed by the message receiver are automatically forwarded to its parents. When a suitable method is found in a parent object (the method holder) it is executed after binding its implicit self parameter. This parameter refers to the object on whose behalf the method is executed. It is also called this (in Java and C++) and current (in Eiffel).

The Difference

Automatic forwarding with binding of self to the message receiver is called delegation.
Automatic forwarding with binding of self to the method holder is called consultation.

Figure 1: Different effect of delegation and consultation on self / this

An Example

The message empJohn.currentPhone#() produces the result "550055" when the object empJohn delegates to persJohn and "669966" when empJohn consults persJohn.


Figure 2: Different result of the same message for delegation and consultation

Intuition / Mnemonic

 

Intuitively, delegating a message means asking another object to do something on behalf of the message receiver, i.e. as if the message receiver would do it. In contrast, consulting means asking another object how it would do something on its own.

Don´t confuse!

Unfortunately, the term delegation is overloaded with many different meanings. For instance, the "Dictionary of Object Technology" by Firesmith and Eykholt lists five different definitions of delegation. In particular, delegation and consultation as defined above should not be confused with neither of the following:
Invocation =/= delegation
Many programmers, especially those working with Microsoft COM, know delegation as a common implementation technique whereby an object subcontracts all or part of its responsibilities to one or more server objects via message passing. We prefer to call this invocation. Invocation is often used to simulate some aspects of consultation or delegation. Delegation and consultation as defined in Lava are made to free programmers from the costs and possible pitfalls of such simulations.
Object extension =/= delegation
In some theoretical papers the term delegation is used as a synonym for extension of an object by additional methods. From a theoretical point of view the only distinction between the two concepts is that delegation involves different objects whereas extension involves only one (after extension the object still has the same identity). Still, this is an essential difference. It accounts for complications in object extension theories that do not arise with delegation (and vice versa). Therefore the two notions should not be equated.

Home
Delegation
Project
Compiler
Downloads
History
Papers
People
Contact

© 1997-2002 Günter Kniesel Date: 01.08.2005