Search code examples
javamodel-view-controllerclass-design

MVC Game Design Java


I try to create a simple game in Java with the Model-View-Controller pattern.

My currently implementation is that

Model

  • Country
  • Timer
    • Observable
  • Money
    • Observable
    • contains Map < Country,Integer>
    • increases Money on update from Timer

Controller

  • Server
    • adds Gui-Observer to Money and Timer
    • static list of Countries

View

  • ServerGui

    • starts Server
    • gets Money and Timer updates
    • add itself to Server for Observer updates
    • open PlayerView
  • PlayerGui

    • has some countries
    • displays current time and money for each country

ScreenShot:

screenshot of the Game World

Is my current implementation a correct MVC implementation?

Is there something that you would change?


Solution

  • This is just as much an art as it is a science, but one thing that sticks out to me is this: why does your model contain a Timer? Shouldn't that be in the controller? What if you wanted to change the model to support, say, stepping through the simulation?

    But you should stick with whatever design fits best in your head. The whole point of patterns is to make code more maintainable, and the best way to make code more maintainable is to design it in a way that makes sense to the people who have to work on it. Since that's you, you should do whatever makes sense to you, not strangers on the internet.