Middle Man
Symptoms
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.
Contraindications
Some patterns (e.g., Proxy or Decorator) intentionally create delegates. Don't remove a Middle Man that's there for a reason. Middle Man and Message Chain trade off against each other. Delegates provide a sort of façade, letting a caller remain unaware of details of messages and structures. Removing a Middle Man can expose clients to more information than they should know.
 |