hidden pixel

Consultation (Object Oriented Programming) Information

Consultation in object-oriented programming occurs when an object's method implementation consists of a message send of the same message to another constituent object.

Example

class CustomerList
{
List<Customer> customers = new ArrayList<Customer>();
public void add(Customer customer)
{
customers.add(customer); // this is a consultation
}
}

In this example, the add method of CustomerList consults the List instance to implement the semantics of adding a value to the list. Consultation can be very useful if extra conditions or side-effects have to occur on the method invocations. For instance in this example, the add method can be used to check if the customer is not yet in the list, and to check for non-null customer object.

Delegation

Consultation is often incorrectly referred to as delegation. The main differences with delegation are that consultation is explicit in the code not a language mechanism as such, and that consultation does not preserve late binding of self whereas delegation does.

This computer science article is a stub. You can help Wikipedia by expanding it. · ·

Categories:

 

The above information uses material from Wikipedia and is licensed under the GNU Free Documentation License.
Some facts may not have been fully verified for accuracy. [Disclaimers]
This page was last archived by our server on Sun Oct 9 06:45:08 2011.
Displaying this page or its contents does not use any Wikimedia Foundation's resources.
The owners of this site proudly support the Wikimedia Foundation.