Exit e-book
Show all chapters
02
Design of the Tic-Tac-Toe game
02. 
Design of the Tic-Tac-Toe game

Sign up to our Newsletter

Signing up to our newsletter allows you to read all our ebooks.

I agree to receive marketing communication from Scalac.
You can unsubscribe from these communications at any time. For more information on how to unsubscribe, view our Privacy Policy.

Mastering Modularity in ZIO with Zlayer
02

Design of the Tic-Tac-Toe game

Before implementing the Tic-Tac-Toe game, let’s take a look at the design considerations we should take into account:

  • It should be a command-line application, so the game should be rendered into the console and the user should interact via text commands.
  • The application should be divided into three modes, where a mode is defined by its state and a list of commands available to the user. These modes should be:
    • Confirm Mode: This mode should just await user confirmation, in the form of yes/no commands.
    • Menu Mode: This mode should allow the user to start, resume or quit a game.
    • Game Mode: This mode should implement the Game Logic itself and allow the user to play against an Opponent AI.
  • Our program should read from the Terminal, modify the state accordingly and write to the Terminal in a Loop.
  • We’d also like to clear the console before each frame.

We will create a separate module for each of these concerns. Each module will depend on other modules as depicted in the image below (the red modules are the ones we need to implement, the white modules are provided by ZIO):

modularity in zio
PREVIOUS
Chapter
01
NEXT
Chapter
03