I am wondering if an object asking a question to another object that indirectly holds it is a “bad” design. For instance...
Requirements: The symbol (object) moves along the grid. When he tries to move to another place, he needs to know if this place is occupied by what blocks him, or if this part of the grid is completely inaccessible. (Note that the character himself must know).
In the application, the state contains the tilemanager and charactermanager. The tile manager knows which tiles are available and which are not. The denominator knows the tile locations of the characters.
It would be reasonable for the character to call a function from a state, say AuthorizeMovement, which determines whether movement through his TileManager and CharacterManager is possible, and returns true if so, false if not?
Is this a violation of any important principles leading to trouble on the road?
Obviously, this is generalized and divided into what is needed to understand the problem.
source
share