Overview
This is very similar to the Message Chains code smell, but with the difference that there, the pizza supplier was ordered to go through a long chain of method calls. Here, the pizzeria supplier additionally delivers “pizza” through that long chain of method calls, with “pizza” present in each of the method parameters. This is an indicator of Dubious Abstraction code smell - the data that pass through long chains of calls, most likely at least one of the levels, are not consistent with the abstraction presented by each of the routine interfaces. [1]
Causation
This can happen due to a cheap way of Global Data code smell refactorization.
Problems
The functionality should be as close to the data it uses as possible. This doesn't seem to be the case when Tramp Data is present.
Example
1class Game:
2 timer: int
3 match: Match
4
5 def start_turn():
6 match(timer).field(timer).players(timer).troops(timer)Exceptions
In the context of the system as a whole, some communication between modules must take place. All possibilities should be properly balanced so that none of the smells dominate (Global Data, Tramp Data, Message Chain, Middle Man) to make the entire codebase as straightforward as possible.
---
Refactoring
- Extract Method
- Hide Delegate
- Move Method
Sources
- ORIGIN
- ORIGIN1993 · ISBN 978-1556154843