Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cyclic dependency between GameState and Decision #3

Closed
LucidTaZ opened this issue Feb 22, 2017 · 2 comments
Closed

Cyclic dependency between GameState and Decision #3

LucidTaZ opened this issue Feb 22, 2017 · 2 comments

Comments

@LucidTaZ
Copy link
Owner

Currently GameState knows about Decision and vice versa. This is not really good design and should be eliminated. When solved, it will make the program easier to reason about. Also, it doesn't force a bad practice onto interface implementers.

GameState's knowledge lies in GameState::getDecisions(): Decision[] and Decision's knowledge lies in Decision::apply(GameState): GameState.

One possible solution is to move apply from Decision to GameState. It could also help to think about extracting a Board class from GameState and making only that known to Decision. However, care should be taken to keep the interface as simple as needed.

@LucidTaZ
Copy link
Owner Author

Note: if we go with the GameState::applyDecision(Decision): GameState approach, we will probably get into trouble with type invariance.

@LucidTaZ
Copy link
Owner Author

Solved by removing Decision and moving its concern into GameState. #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant