Back to Catalog
Code Smells
Couplers
Message Chains
Long chains of method calls that make code fragile.
Intent & Description
'
🎯 Intent
Identify long chains of method calls (a.b().c().d()) that make code fragile to changes.
📋 Context
You have code that calls methods on objects returned from other method calls, creating long chains that break easily.
💡 Solution
Hide delegate objects using Hide Delegate, or extract methods to shorten the chains.'
Real-world Use Case
Use when method call chains are long and brittle.
Source
📌 TL;DR
Long method chains are fragile. Hide intermediate objects or extract methods to shorten chains.