---
title: "Remove Middle Man"
type: "refactoring-technique"
slug: "remove-middle-man"
url: "http://localhost:3000/en/remove-middle-man.md"
category: "Moving Features between Objects"
description: "Problem: A class has too many methods that simply delegate to other objects. Solution: Delete these methods and force the client to call the end methods directly."
---
# Remove Middle Man

> Problem: A class has too many methods that simply delegate to other objects. Solution: Delete these methods and force the client to call the end methods directly.

## Problem

A class has too many methods that simply delegate to other objects.

## Solution

Delete these methods and force the client to call the end methods directly.

## Why Refactor

To describe this technique, we’ll use the terms from [Hide Delegate](/hide-delegate), which are:

* _Server_ is the object to which the client has direct access.
* _Delegate_ is the end object that contains the functionality needed by the client.

There are two types of problems:

1. The _server-class_ doesn’t do anything itself and simply creates needless complexity. In this case, give thought to whether this class is needed at all.
2. Every time a new feature is added to the _delegate_, you need to create a delegating method for it in the _server-class_. If a lot of changes are made, this will be rather tiresome.

## How to Refactor

1. Create a getter for accessing the _delegate-class_ object from the _server-class_ object.
2. Replace calls to delegating methods in the _server-class_ with direct calls for methods in the _delegate-class_.
## Relations

**Opposite refactorings**

- [Hide Delegate](/en/hide-delegate.md)

**Eliminates smells**

- [Middle Man](/en/smells/middle-man.md)

