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.