Last weekend we went to the American Museum of Natural History to attend the Día de Muertos festival. The program itself was awesome and overall it was a fantastic experience. What surprised me the most during this visit, and definitely my personal highlight, is that it made me remember a game I used to play when I was a kid called: Lotería.
This made me recall yet another thing: the rules to play Lotería are pretty straightforward, it’s sort of like a “Mexican Bingo”.
Hear me out! All of this is going to make sense, wait for it.
With those facts and the need I’ve been having of finding a “real” project, big enough yet easy to understand to use as an example (so a lot of people can benefit from it) for showing off Domain Driven Design and Go is what encouraged me to start this new “initiative”.
At work we have our own proprietary domain, and obviously I can not share that with you all, and I didn’t want to use the usual “To Do program” because that really does not help that much, IMO.
Domain Driven Design is not something new, it’s been here for more than a decade already, however in recent years has become more relevant because of the popularity of Microservices and how those are meant to be designed to do one single thing only the best way possible.
Domain Driven Design literature is vast, there are thousands of resources describing concrete implementations in different frameworks and programming languages, however not that many idiomatic ones in Go. I know Ben and Peter are the prominent experts of showing us “how to do it” in Go, but still those specific resources are far from what I can consider a full working example.
So, starting today I’ll be implementing this new project, a game using concrete Domain Rules that will evolve into a much more complex “production-like” service that is idiomatic and follows, as best possible, the Domain Driven Design software development approach.
If you’re not familiar with Domain Driven Design, I highly recommend you watching this online course:
- Part 1: Overview and Core Values of Domain-Driven Design,
- Part 2: Strategic Design: Domains, Subdomains, Bounded Contexts & Context Maps,
- Part 3: Internal Building Blocks: Aggregates, Entities, Value Objects Part 3/5,
- Part 4: Domain Events & Event Storming Part Four, and
- Part 5: is not yet out.
and reading the original resources:
- Domain-Driven Design: Tackling Complexity in the Heart of Software 1st Edition
- Patterns, Principles, and Practices of Domain-Driven Design
Let’s start now! Lotería Domain
Lotería Mexicana‘s simplest variant consists of the following rules:
- There is a deck with 54 cards,
- There are N players, each player is given one Tabla (Board),
- Tablas always have a randomly created 4x4 grid of cards,
- Given tablas are unique during the duration of the game,
- There’s a Cantor (Announcer), who is in charge of randomly selecting cards from the deck,
- Players have to listen to the announced cards and mark them on their boards,
- The winner is determined by the first player who shouts “LOTERÍA!" and (more importantly) has four sequential marked cards in a horizontal, vertical or diagonal row.
That being said, let’s take a break for now, digest everything and come back tomorrow.