tags:

views:

325

answers:

2

I am trying to make the domain model of a Tic Tac Toe game. I'll try then to go on through the various steps of the Unified Process and later implement it in some language (C# or Java).

I'd like to have some feedback if I'm going on the right path: alt text

I've defined the game with two actors, Player O and Player X.

  1. I'm not sure about defining both a Tile and a Tile State. Maybe I should only define a Tile and have the 3 possible states specialize from it?
  2. I'm not sure what is best: to have both Player O and Player X be associations with Tic Tac Toe or have them inherit from Player that is associated with Tic Tac Toe. Following the design shown on the pic, in theory we could have a Tic Tac Toe concept with 2 Player O's, which wouldn't be correct. What is your opinion on this?

Also, am I missing something in the diagram? Although I can't see any other actors for Tic Tac Toe, should I have any other?

Thanks

+4  A: 

An alternative class decomposition would be to replace Board and Tile with Game and Move. A game would contain a legal series of Moves, and a Move would contain the square coordinates (or some other identifier) and whether it was player O or X. This scheme holds a little more information allowing the game can be replayed and backed up.

bbudge
+1  A: 

To your diagram:

  1. is constituted by should be composition relation, not association (Tiles cannot exist on their own, the state of Board is defined by the state of its Tiles.)
  2. Player O and Player X are instances of the Player class, not subclasses (Player 0 and Player X have same structure as Player, they have same behaviour, the difference is in identity and state - name in your diagram)

When you are talking domain model (in context of UP), you should forget about creating a software system and include only what is important for the domain of the tic tac toe game. Think of how any game is described - it has its rules (preparation, turns, game end conditions, ...), players (with identity for more games, points, owned/controlled components, roles ...) and physical components (boards, tokens, figures, cards...). If you accept those elements to be part of the domain model for games and therefore metamodel for your tic tac toe game, you should use elements, which are instances of that elements.

Gabriel Ščerbák