Delegation

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: Delegation is a design pattern which involves an object that delegates certain responsibilities to an associated object called a delegate. As an example, the Cocoa framework contains a cl...)
 
m (Reverted edits by Ebybymic (Talk); changed back to last version by Joey Scarr)
 
(3 intermediate revisions by 3 users not shown)
Line 2: Line 2:
  
 
As an example, the Cocoa framework contains a class called NSTableView, which is a user interface control which presents a scrollable list of selectable rows. It can use a delegate for numerous tasks such as to get the height of a row or to provide tool tips for cells.
 
As an example, the Cocoa framework contains a class called NSTableView, which is a user interface control which presents a scrollable list of selectable rows. It can use a delegate for numerous tasks such as to get the height of a row or to provide tool tips for cells.
 +
 +
When considering use of the delegation pattern, the intended use is important. If you just want to use it to notify an object about certain events rather than delegating responsibilities, consider the [[Observer]] design pattern instead.
 +
 +
It's worth noting that this pattern is different to the concept of ''delegates'' in languages such as C#, which are essentially a built-in language construct providing support for the [[Observer]] pattern.
  
 
[[Category:Design Patterns]]
 
[[Category:Design Patterns]]

Latest revision as of 03:03, 25 November 2010

Delegation is a design pattern which involves an object that delegates certain responsibilities to an associated object called a delegate.

As an example, the Cocoa framework contains a class called NSTableView, which is a user interface control which presents a scrollable list of selectable rows. It can use a delegate for numerous tasks such as to get the height of a row or to provide tool tips for cells.

When considering use of the delegation pattern, the intended use is important. If you just want to use it to notify an object about certain events rather than delegating responsibilities, consider the Observer design pattern instead.

It's worth noting that this pattern is different to the concept of delegates in languages such as C#, which are essentially a built-in language construct providing support for the Observer pattern.

Personal tools