I'm working on a simple board game that will run in the browser. I'm thinking how to structure the program and I'd like to hear your opinions.
The program will consist of the user interface part (the logic that handles key presses, manipulates Html, etc.), and of the data-and-logic part (makes decisions on how to update the game and stores the state of the game).
I can think of two options regarding how to structure this:
A- The business logic module references the display module.
Advantages:
The display knows nothing about the business logic.
Easy to inject the display to the business logic.
Disadvantage: how can the business logic be notified when the user performs an action?
B- The display module references the logic module.
Advantage: the display can easily notify the business logic when the user performed an action.
Disadvantage: the display knows about the existence of the business logic.
Which design is better, and why?