Quote:
Originally Posted by bytor99999
OK, this is more a statement than a question.
Delegation had been giving me a little problem when trying to create one myself, rather than the common implementing the TableView delegate methods.
So, after reading and examining, this is the Template Method design pattern. So why did they change the name to delegation. Just to confuse those who already know design patterns? Just to be different?
|
Sorry, I disagree. delegation is a different design pattern than the Template Method design pattern. In Template Method, you create methods that you then override in your subclasses to fine-tune the behavior of the classes.
Delegation is different. Delegation allows one object (the delegate) to modify the behavior of another object. It is possible to assign different delegates to different instances of an object at runtime, which can cause identical objects with different delegate objects to behave differently.
Delegates are also very useful for things like async operations. You create an object to handle an async process, and assign a delegate that gets notified at key points in the async process.
An object is only aquatinted with it's delegate, but in the template method, the abstract object and its subclass are aggregated.
Apple's delegation design pattern
IS the gang of 4 delegation pattern. Why do you say it's closer to the template method pattern?