Delegation
© Copyright Frank D. Kanu 2000-2008
Delegation:
Passing a message from one object to another; the first object delegates the responsibility to the second object
For every event there will be a listener to which the event will be passed; thus the name Delegation Model/Pattern. Originally the name Command-Model was used, but it was thought that is does not match to closely the functionality of it.

Delegate pattern are a big part of OS, like NeXTSATEP, OPENSTEP and Mac OS X
A delegate can implement methods, but that is not a must. Does an event arrives and the object knows a delegate, which does have the method implemented then it does call a method directly or better sends a message to the delegate. The Delegate pattern has many similarities with the Goal or Reducer pattern.
Another example which matches the delegation pattern is the collection. Collections in JDK 1.2 are not thread safe. To avoid the need of synchronizing all manipulations to the collection there are some methods to make an un-sychronized collection synchronized:
In the OO programming world there are two different ways of re-using code: inheritance and delegation. This becomes a design pattern when an object delegates work which should have done by itself. In that case it makes the most sense to force delegation and use the delegate pattern. A perfect example are classes with identical functionality in them, but the classes do not belong to the same family, eg classes from the swing toolkit.

Literature:
Fowler, Martin Refactoring - Improving the Design of Existing Code
Blair, G.S.; Gallagher, J.J.; Malik, J.: Genericity vs. Inheritance vs. Delegation vs. Conformance vs …. In: Journal of Object-Oriented Programming. Sep./Oct., 1989, S. xx-xx
Booch, G.: Object-Oriented Analysis and Design with Applications. 2. Aufl., Redwood City 1994
Frank, U.: MEMO: A Tool Supported Methodology for Analyzing and (Re-) Designing Business Information Systems. In: Ege, R.; Singh, M.; Meyer, B. (Ed.): Technology of Object-Oriented Languages and Systems. Englewood Cliffs 1994, S. 367-380
Gamma, E.; Helm, R.; Johnson, R.; Vlissides, J.: Design Patterns. Elements of Reusable Object-Oriented Software. Reading/Mass. etc.: Addison-Wesley 1995
Jacobson, I.; Christerson, M.; Jonsson, P.; Overgaard, G.: Object-Oriented Engineering. A Use Case Driven Approach. Reading/Mass. 1992
Johnson, R.E.; Zweig, J.: Delegation in C++. In: Journal of Object-Oriented Programming. Vol. 4, No. 11, S. 22-35
Kathuria, R. and Subramaniam, V.: Assimilation: A New and Necessary Concept for an Object Model. REPORT ON OBJECT ANALYSIS & DESIGN, Vol. 2, No. 5, 1996, S. 36-39
Lieberman, H.: Using prototypical objects to implement shared behavior in object-oriented systems. In: OOPSLA, 1986, S. 214-223
Kim, W.; Lochovsky, F. (Hg.) Object-Oriented Concepts, Applications, and Databases. New York 1989
Rumbaugh, J. et al.: Object Oriented Modeling and Design. Englewood Cliffs, NJ 1993
Sciore E.: Object specialization. In: ACM Transactions on Office Information Systems, Vol. xx, No. xx, 1989, S.
Smith, R.B.; Ungar, D.: Programming as an Experience. The Inspiration for Self. In: Proceedings of the ECOOP 95
Stein, L.A.: Delegation is Inheritance; oopsla, 1987
Technorati (All Links are external): assimilation business information systems c static code inheritance collection c delegate delegates delegation delegation model design design pattern design patterns driven approach ege martin fowler functionality jdk listener match method implemented model report object model object oriented analysis object oriented languages object oriented programming object oriented software oo programming programming world reading mass refactoring reusable object oriented software static collection swing toolkit synchronized synchronizing two different ways it
Delegation:
Passing a message from one object to another; the first object delegates the responsibility to the second object
For every event there will be a listener to which the event will be passed; thus the name Delegation Model/Pattern. Originally the name Command-Model was used, but it was thought that is does not match to closely the functionality of it.

Delegate pattern are a big part of OS, like NeXTSATEP, OPENSTEP and Mac OS X
A delegate can implement methods, but that is not a must. Does an event arrives and the object knows a delegate, which does have the method implemented then it does call a method directly or better sends a message to the delegate. The Delegate pattern has many similarities with the Goal or Reducer pattern.
Another example which matches the delegation pattern is the collection. Collections in JDK 1.2 are not thread safe. To avoid the need of synchronizing all manipulations to the collection there are some methods to make an un-sychronized collection synchronized:
static Collection synchronizedCollection(Collection c)
static List synchronizedList(List list)
static Map synchronizedMap(Map m)
static Set synchronizedSet(Set s)
static SortedMap synchronizedSortedMap(SortedMap m)
static SortedSet synchronizedSortedSet(SortedSet s)In the OO programming world there are two different ways of re-using code: inheritance and delegation. This becomes a design pattern when an object delegates work which should have done by itself. In that case it makes the most sense to force delegation and use the delegate pattern. A perfect example are classes with identical functionality in them, but the classes do not belong to the same family, eg classes from the swing toolkit.

Literature:
Fowler, Martin Refactoring - Improving the Design of Existing Code
Blair, G.S.; Gallagher, J.J.; Malik, J.: Genericity vs. Inheritance vs. Delegation vs. Conformance vs …. In: Journal of Object-Oriented Programming. Sep./Oct., 1989, S. xx-xx
Booch, G.: Object-Oriented Analysis and Design with Applications. 2. Aufl., Redwood City 1994
Frank, U.: MEMO: A Tool Supported Methodology for Analyzing and (Re-) Designing Business Information Systems. In: Ege, R.; Singh, M.; Meyer, B. (Ed.): Technology of Object-Oriented Languages and Systems. Englewood Cliffs 1994, S. 367-380
Gamma, E.; Helm, R.; Johnson, R.; Vlissides, J.: Design Patterns. Elements of Reusable Object-Oriented Software. Reading/Mass. etc.: Addison-Wesley 1995
Jacobson, I.; Christerson, M.; Jonsson, P.; Overgaard, G.: Object-Oriented Engineering. A Use Case Driven Approach. Reading/Mass. 1992
Johnson, R.E.; Zweig, J.: Delegation in C++. In: Journal of Object-Oriented Programming. Vol. 4, No. 11, S. 22-35
Kathuria, R. and Subramaniam, V.: Assimilation: A New and Necessary Concept for an Object Model. REPORT ON OBJECT ANALYSIS & DESIGN, Vol. 2, No. 5, 1996, S. 36-39
Lieberman, H.: Using prototypical objects to implement shared behavior in object-oriented systems. In: OOPSLA, 1986, S. 214-223
Kim, W.; Lochovsky, F. (Hg.) Object-Oriented Concepts, Applications, and Databases. New York 1989
Rumbaugh, J. et al.: Object Oriented Modeling and Design. Englewood Cliffs, NJ 1993
Sciore E.: Object specialization. In: ACM Transactions on Office Information Systems, Vol. xx, No. xx, 1989, S.
Smith, R.B.; Ungar, D.: Programming as an Experience. The Inspiration for Self. In: Proceedings of the ECOOP 95
Stein, L.A.: Delegation is Inheritance; oopsla, 1987
Tags:
assimilation business information systems c static code inheritance collection c delegate delegates delegation delegation model design design pattern design patterns driven approach ege martin fowler functionality jdk listener match method implemented model report object model object oriented analysis object oriented languages object oriented programming object oriented software oo programming programming world reading mass refactoring reusable object oriented software static collection swing toolkit synchronized synchronizing two different waysTechnorati (All Links are external): assimilation business information systems c static code inheritance collection c delegate delegates delegation delegation model design design pattern design patterns driven approach ege martin fowler functionality jdk listener match method implemented model report object model object oriented analysis object oriented languages object oriented programming object oriented software oo programming programming world reading mass refactoring reusable object oriented software static collection swing toolkit synchronized synchronizing two different ways it







