nchnsn / othello

0 stars 1 forks source link

Outline Clear MVC #11

Open nchnsn opened 7 years ago

nchnsn commented 7 years ago

Restructure the game so that there's separate files/clearly defined model, model, view, controller.

nchnsn commented 7 years ago

@jfsiii As a first step to the refactor, I came up with an outline of how I would structure the MVC of my game, as well as some of the initial tests I could start with. Could you take a look my outlines, I just want to make sure I am thinking about it the right way: MVC and Testing Outline

jfsiii commented 7 years ago

@nchnsn It's been awhile since I've dealt with MVC. Even then, there are debates over responsibilities and MVC vs MVVM. Caveats aside, here are my thoughts:

The Model is all about the data. Not just the actual data structure, but also any methods to alter it.

The View is the "projection" or visual representation of that data.

The Controller connects the two. It observes the view and converts user inputs (click, drag, etc) into commands for the Model. It can alter the View directly or re-render the based on the updated state (Model data).

Based on that outline, I'd move many of your controller features to the model. You should be able to "play" the game from a test by calling the appropriate model methods. The Controller merely translates certain inputs into the correct commands on the Model.

nchnsn commented 7 years ago

Awesome, thanks. Controlling from tests is a great way of thinking about it (and will also help me with my testing).