Executable domain-driven design: the Ludo game case study

Moldable Development can be applied to any aspect of a software system, including for explaining a domain. In this example, we take a look at an implementation of Ludo, a simple strategy game for 2-4 players.

To learn about the implementation of the game, you can follow the tutorial from Implementing a Ludo Game as a moldable development exercise. In this page, we look at leveraging the inside of the systems for documentation purposes.

Exploring the game

When developing systems, we use Examples to express tests. But as examples also return objects, we can combine them with custom views to produce documentation.

Here is such an example that builds a game object, and that knows how to draw itself. In this case, it draws the actual game and you can play it right here.

Documenting the moves of the game from an end-user perspective

The primary use of these examples is to drive the implementation. However, they can also directly be leveraged for documenting various facets of a system. Here we use them to describe the moves of the game from the perspective of an end-user.

The initial move

A regular move

A move to the end

An impossible move

Jumping over one's own token

Capturing another player's token

Documenting the history of a game for debugging purposes

The same visualizations can be used for debugging purposes as well. For example, here is an Inspector opened on a game object that has multiple moves. Take a moment to explore the different facets and the interconnected objects.