Talk:Delegation pattern
From Wikipedia, the free encyclopedia
Contents |
[edit] Examples
I think the proliferation of examples is problematic. I think the following issues need to be considered,addressed.
- Are two Java examples necessary. - Are C++ and Objective C examples necessary. - All example languages are similar, where are the examples in functional or declarative languages, or even a notational example e.g. UML. - Perhaps all programming languages should use a consistent example. MartinSpamer (talk) 11:47, 17 December 2007 (UTC)
[edit] Delegation vs. Proxy pattern
The Delegation and Proxy pattern look very much alike. Some more information in the differences and similarities between those two patterns would be welcome here. Avernet 18:54 19 Jun 2003 (UTC)
They are similar. I would classify Proxy to be a specialisation of the more general delegation pattern. In the Proxy both the Subject and the Proxy conform to the same interface, this isn't the case with delegation. MartinSpamer —Preceding unsigned comment added by MartinSpamer (talk • contribs) 12:31, August 29, 2007 (UTC)
I've heard a lot of people talking about the ‘delegation’ pattern lately. I wondered why? It's not a classic GOF pattern. There might be a few legitimate reasons to use it, but I've yet to hear a compelling reason. Unlike the ‘proxy’ pattern which serves a legitimate purpose, the ‘delegation’ pattern seems like a code bloating anti-pattern to me. Why is it so popular? I just bought Wiley's Patterns in Java Volume 1. Sure enough, it's the first pattern listed. Ah!
You are right to say that it's not a classic GOF pattern. The GOF book considers delegation to be a technique that forms a building block for several patterns (e.g. State, Strategy, Visitor), rather than a pattern in itself. There's a section on Delegation in the introduction of the GOF book. —Preceding unsigned comment added by 194.133.18.67 (talk) 08:18, 3 April 2008 (UTC)
[edit] Observations
The criticisms section is making non-submissible arguments.
The criticism is based on the observation that an incorrect implementation may not work correctly. This is a tautology and holds for any code in any language. If the design pattern was complicated to the extent that writing a correct implementation is considered difficult, then that would be a valid criticism.
Also I suggest an 'applicability' section describing an example of where this pattern may be preferable to an alternative such as standard OO inheritance, and perhaps a case where this pattern is less-preferable than an alternative pattern etc..
[edit] Applicabilty
I added an applicabilty section in PHP. Feel free to switch this to something more mainstream such as java or C++. This should clarify the use of this pattern and also clear up any confusion between this and the proxy pattern.
I browsed through the various patterns on wikipedia and found the majority of the text borderline useless and confusing. Additionally there are very few discussions on how a particular pattern might be applied to solve a real world problem.
Please comment on the usefulness/clearness of my applicability example. Should it be decent I'll go ahead and start working on the other patterns as well. --Begby 18:10, 2 March 2006 (UTC)
[edit] Suggest merge with Delegation (programming)
The node Delegation (programming) talks at length about the Delegation pattern, yet Delegation pattern already has its own node. Shouldn't they be merged? --Devnevyn 12:47, 11 August 2007 (UTC)
[edit] ObjC example
Hmm. I added an example for Objective-C. Since they call it 'delegates', I assumed it was the delegation pattern. However, after actually RTFA I realize that it doesn't seem to be at all the same. Does anyone know what my code is actually a pattern of, so that I can move it to a more appropriate place? Or does it actually fit here? --Devnevyn 13:19, 11 August 2007 (UTC)
[edit] This and pimpl
Isn't this just a more general case of Opaque_pointer. If so, maybe some information linking the two should be present. 202.10.86.59 11:42, 31 October 2007 (UTC)
[edit] Motivation and use
I cannot extract from the article when it's best to use this pattern. Can someone give a motivation or an example in which situation it's good to use this pattern. I know that it in Java e.g. it's used by swing. But I don't know with which aim. Maybe it would be good, to add an motivation section to the article. 80.144.128.176 (talk) 10:25, 11 March 2008 (UTC)
I found this, which makes it a little clearer: http://best-practice-software-engineering.ifs.tuwien.ac.at/patterns/delegation.html
80.144.128.176 (talk) 10:54, 11 March 2008 (UTC)