oop - OO Design - Object asks question to class that indirectly holds it -


I'm wondering if there is a question that puts an object indirectly to another object "bad" design For example ...

Requirements: Character (an object) runs on a grid. When he tries to move to another place, it is important to know whether the place is already locked from something which blocks it or if that part of the grid is not fully accessible. (Note that it is necessary to know the character only).

In the application, in a state there is a tile-maker and a chair. Tilemanager knows what tiles are available and which are not. The character knows the tile locations of the letterhead

Whether it is appropriate for the character to call a function for the state, call it AuthorizeMovement , determines whether the movement is done by its tile manager and character manager Is possible through medium, and if false, if not false?

Does it violate any important principles, which can disturb the road?

Obviously this is normalized and it is important to understand this problem.

I do not see any problems. Good o design comes with many principles, but at the root of it you have a bigger 4: incapulation, inheritance, polymorphism, and abstraction. In addition, you want high restraint and less coupling, your objects / sections may fit anywhere and not connected to any particular implementation or class.

It has been said that it seems like you have divided the encapsulated movement and the characters into different classes. So your character is not directly modifying the class board, which would be bad if it happens.

When you get a deeper understanding of your problem, you can always refactor code to improve your design to take advantage of you. Other Principles


Comments