Delegation, is this just opinionated or is there a common pattern?
Posted
by
user1446714
on Stack Overflow
See other posts from Stack Overflow
or by user1446714
Published on 2012-06-09T21:49:28Z
Indexed on
2012/06/09
22:40 UTC
Read the original article
Hit count: 234
If I have a java class containing substantial code and I wish to add extra features, am I right in thinking the delegate class would have the additional features added as methods. Then my original class would create the delegate object and just call the extra functionality via the delegate instance?
I am being told by somebody else that my original class should become the delegate and that the class containing the new functionality should contain an instance of the original class, to use as a delegate? This seemed a little backward to me, because there would be far more delegate calls because most of the code is now in the delegate....
I was always under the impression the delegate object would contain the additional new behaviour and an instance of it would be in the original class to inboke the new behaviour from?
© Stack Overflow or respective owner