---
title: "Message Chains"
type: "code-smell"
slug: "message-chains"
url: "http://localhost:3000/en/smells/message-chains.md"
category: "Couplers"
description: "In code you see a series of calls resembling $a->b()->c()->d()"
---
# Message Chains

> In code you see a series of calls resembling $a->b()->c()->d()

## Signs and Symptoms

In code you see a series of calls resembling `$a->b()->c()->d()`

## Reasons for the Problem

A message chain occurs when a client requests another object, that object requests yet another one, and so on. These chains mean that the client is dependent on navigation along the class structure. Any changes in these relationships require modifying the client.

## Payoff

* Reduces dependencies between classes of a chain.
* Reduces the amount of bloated code.
## Relations

**Treated by**

- [Hide Delegate](/en/hide-delegate.md)
- [Extract Method](/en/extract-method.md)
- [Move Method](/en/move-method.md)


## Detected by

- **pmd** `LawOfDemeter` — Law of Demeter (chained calls) (https://docs.pmd-code.org/latest/pmd_rules_java_design.html#lawofdemeter)
