I want to write a simple game application, for example Chess or Monopoly.
I want to have to separate classes Game and UI.
I wonder what is the best way to communicate between thees two classes. By events? By saving reference to ui in Game object ?
I want to separate the logic from ui.
any comments are appreciated.
thnx.
Sam HobbsPosted Feb 6, 2010, 3:14 PM
I would design it so that the game logic calls the UI. I think it would be good design for the game logic to know about the UI. The UI should exist for the details of the UI; the main logic would not be in the UI.
In business software, a popular philosophy is to use three layers; a Data Access Layer (DAL), a Business Layer Logic (BLL) and the UI. You can search for articles about that; there are even books about it. It is probably relevant to games also.
Eduard GPosted Feb 6, 2010, 5:01 AM
but the question is what is the best way to let UI know that player1 has won the game, for example? Is it OK to keep the reference to the Game objec in the UI controll, or to keep UI reference in the Game controll, or notify UI by fireing an event, or throwing an exception?
Sam HobbsPosted Feb 5, 2010, 2:13 PM