Consultation (object-oriented programming)

Consultation (object-oriented programming)

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.


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Consultation — may refer to: Public consultation, a process by which the public s input on matters affecting them is sought Consultation (Texas), the 1835 Texas meeting of colonists on a proposed rebellion against the Republic of Mexico Consultation (doctor), a …   Wikipedia

  • Object Pascal — Paradigm(s) imperative, structured, object oriented, functional (Delphi dialect only) Appeared in 1986 (1986) Designed by Apple, Niklaus Wirth, Anders Hejlsberg …   Wikipedia

  • Delegation (programming) — For the authorization related term, see delegation in IT. 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… …   Wikipedia

  • Pascal (programming language) — Pascal Paradigm(s) imperative, structured Appeared in 1970 Designed by Niklaus Wirth Typing discipline static, strong, safe …   Wikipedia

  • Делегирование (программирование) — В объектно ориентированном программировании существуют два смежных понятия делегирования. В современном понимании это означает свойство языка программирования использовать правила поиска метода для диспетчеризации так называемых self calls… …   Википедия

  • Top-down and bottom-up design — Top down and bottom up are strategies of information processing and knowledge ordering, mostly involving software, but also other humanistic and scientific theories (see systemics). In practice, they can be seen as a style of thinking and… …   Wikipedia

  • Software design pattern — In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into code. It is a… …   Wikipedia

  • Design pattern (computer science) — In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for …   Wikipedia

  • Garbage collection (computer science) — This article is about garbage collection in memory management. For garbage collection in an SSD, see garbage collection (SSD). For other uses, see garbage collection. In computer science, garbage collection (GC) is a form of automatic memory… …   Wikipedia

  • MacApp — was Apple Computer s primary object oriented application framework for the Mac OS for much of the 1990s. First released in 1985, it is arguably the first such system to be widely used, notably on a microcomputer platform. Microsoft s MFC and… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”