2015-12-26 22:29:45 +00:00
|
|
|
---
|
2015-12-28 18:16:58 +00:00
|
|
|
layout: pattern
|
|
|
|
title: Delegation
|
|
|
|
folder: delegation
|
|
|
|
permalink: /patterns/delegation/
|
2019-12-13 21:09:28 +02:00
|
|
|
categories: Structural
|
2021-05-19 10:49:05 -06:00
|
|
|
language: en
|
2015-12-28 18:16:58 +00:00
|
|
|
tags:
|
2019-12-13 21:09:28 +02:00
|
|
|
- Decoupling
|
2015-12-28 18:16:58 +00:00
|
|
|
---
|
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Also known as
|
|
|
|
Proxy Pattern
|
2015-12-26 22:29:45 +00:00
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Intent
|
|
|
|
It is a technique where an object expresses certain behavior to the outside but in
|
2015-12-28 18:16:58 +00:00
|
|
|
reality delegates responsibility for implementing that behaviour to an associated object.
|
2015-12-26 22:29:45 +00:00
|
|
|
|
2019-12-07 20:01:13 +02:00
|
|
|
## Class diagram
|
2015-12-28 18:16:58 +00:00
|
|
|

|
2015-12-26 22:29:45 +00:00
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Applicability
|
|
|
|
Use the Delegate pattern in order to achieve the following
|
2015-12-26 22:29:45 +00:00
|
|
|
|
2015-12-28 18:16:58 +00:00
|
|
|
* Reduce the coupling of methods to their class
|
|
|
|
* Components that behave identically, but realize that this situation can change in the future.
|
2015-12-26 22:29:45 +00:00
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Credits
|
2015-12-26 22:29:45 +00:00
|
|
|
|
2015-12-30 18:26:32 +00:00
|
|
|
* [Delegate Pattern: Wikipedia ](https://en.wikipedia.org/wiki/Delegation_pattern)
|
2016-01-03 21:14:30 +01:00
|
|
|
* [Proxy Pattern: Wikipedia ](https://en.wikipedia.org/wiki/Proxy_pattern)
|