19 August 2007
Overlaying application flow onto HMVC
I need to put the conclusions of the past two posts together- I need to decompose the application structure implied by my flow diagram into a set of HMVC triads as described below.
The top level triad will have responsibility for moving the application from one phase, i.e. the game creation stage or the end game stage, to the next, and also for providing RPC functionality - I don't want that kind of code just spotted round the place. The Root/Container Triad:
- Model: Contains RPC methods and global state.
- View: Practically none - contains "Loading..." view.
- Controller: Co-ordinates transistions from one Triad to another.
After the Root triad has obtained the stack of Trumps for that appropriate player, it creates a child Triad to "setup" the game: The Create Game Triad:
- Model: Instantiate Game, Set players, Shuffle cards, Deal Cards, Toss Coin.
- View: Welcome and display outcome of game initialisation.
Next the Create Game Triad signals it is finished and the Root controller destroys that entire triad, replacing it with the Game Triad, which again is a child of the root controller. Due to the complexities of this view it is decomposed into further HMVC triads which are orchestrated by the Game Triad Controller:
- Player Turn VC Triad
- Opponent Turn VC Triad
- Show Result VC Triad
These are "cut-d0wn" HMVC triads, consisting only a view and a controller. All of the model code however is contained within the higher level Play Game Triad. Messages are passed between components and the Play Game Controller will create and destroy the alternate child Triads as required. Therefore the Play Game Triad looks like this:
- Model: Evaluate winner of turn functionality, Determine if game has been won functionality.
- View- Several View/Controller Triads as above.
- Controller: Manage interactions between all these! Create/Destroy child Triads.
Finally there is a End Game Triad to display the winner of the game and offer the oppotunity to return to the beginning of the game.
- Model: Send result via RPC (I will actually leave this until the next iteration of the game).
- View: Show End Result.
- Controller: Allow to go back to the start.
The structure described above will allow me to decompose my code into disgestible modular chunks and also due to the separation of functionality and standardisation of messaging will allow easy modification and improvement later. It won't be a matt of spaghetti.
Labels: approach, facebook api, gwt, hmvc, java
