Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Chapter 10. Responsibility > Challenges - Pg. 62

Responsibility 62 Middle Man Symptoms · Most methods of a class call the same or a similar method on another object: f() {delegate.f();} (A class that mostly delegates its work is known as a middle man .) Causes For one thing, this can result from applying Hide Delegate to address Message Chains. Perhaps other features have moved out since then, and you're left with mostly delegating methods. What to Do · In general, Remove Middle Man by having the client call the delegate directly. · If the delegate is owned by the middle man or is immutable, and the middle man has behavior to add, and the middle man can be seen as an example of the delegate, you might Replace Delegation with Inheritance. Payoff Reduces size. May improve communication.