- one class called Game (place holder, the class is not really required) with one method called move(int number_on_the_dice)
- a list to hold the current position of each player on the board (there can be more than 2 players)
- a hashmap with starting and ending points on the board (represents both the snakes and ladders, how does it matter whether its a snake or a ladder, they are just starting and ending points on the board)
- a counter to calculate player’s turn
- and … and what? …that’s it
TDD is not only about testing and design. TDD suppose to help us to uncover the unexpected so that we can make the necessary trade-off in our design. We should not just focus on creating objects or tests during TDD. We should pay attention to the signs in our code, which we call code smell. For example, if our ladder and snake objects have the same attributes (starting and ending point), we should pause and think a little bit. It seems like we have code duplication in different objects. It is no different than having similar code in two different methods. We should strive to eliminate code duplication. But, before we do that, we need to ask ourselves a few questions:
- Will the additional object help to communicate the domain concept better to the next developer?
- Will the additional object help to communicate the domain concept better to the business user?
- Is the domain concept complex enough to warrant a separate domain object?
- Is there a hidden domain concept that can represent both snake and ladder domain concepts?