Last Revision — April 19, 2022
2 Min Read
---
Data Dealers
Data
Between Classes
- Message Chain (family)
- Long Parameter List (co-exist)
- Dubious Abstraction (co-exist)
- Global Data (antagonistic)
Steve Smith in course (2013):
"Refactoring Fundamentals"
Steve McConnell in book (1993):
"Code Complete"
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]
This can happen due to a cheap way of Global Data code smell refactorization.
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.
class Game:
timer: int
match: Match
def start_turn():
match(timer).field(timer).players(timer).troops(timer)
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.