DEV Community

Cover image for Using F# and DDD to create an online card game

Posted on

Using F# and DDD to create an online card game

(this post was imported from Medium)

In the last days, I have been studying a book that sparkled the beginner's excitement in me — a feeling that was a long time gone. The book is called Domain Modeling Made Functional, written by Scott Wlaschin, and is about using a functional language to design software following the principles from Domain-Driven Design (DDD).

DDD and F# made me realize that there's still so much that can be done to improve the quality and reliability of software that we write.

"Domain-Driven Design is an approach to software development that centers the development on programming a domain model that has a rich understanding of the processes and rules of a domain."

A nice quote from Domain Modeling Made Functional about DDD:

"If you think of software development as a pipeline with an input (requirements) and an output (the final deliverable), then the "garbage in, garbage out" rule applies. If the input is bad (unclear requirements or bad design), then no amount of coding can create a good output.
(…) we'll look at how to minimize the "garbage in" part by using a design approach focused on clear communication and shared domain knowledge: domain-driven design, or DDD.

Since I know that the best way to learn is to practice what I'm studying, I challenged myself to write an online version of a simple but very nice card game that I play with my friends.

The game is called Dutch Blitz and I see it as a "multi-player solitaire". It's important to notice that this is a study project and I don't intend to make any money with this game.

In order to register my progress, I decided to write a series of posts about the theme.

What are the technologies that I want to learn in order to build an online version of this game?

  • F# in the server
  • Elm in the client
  • Websockets
  • Azure to deploy the code (because I'll use F#)
  • Whatever else I need to build multiplayer games (I’ll edit this section as I learn what these things are)

The initial goals for this game are:

  • [ ] Have a pure (no side-effects) functioning engine tested with TDD. I'll use DDD to model the domain.
  • [ ] Have a functioning real-time multi-player state handler
  • [ ] A simple, four-player, UI
  • [ ] other stuff that I'll write as soon as I figure more things out

I won't spend a lot of time thinking about the architecture in the first moment. I'll think about it only after I have modeled the game domain.

Since I'm a beginner, I expect to make wrong assumptions about the domain and to use DDD/F# in the wrong ways many times as I learn and make progress. But it's ok! Learning involves making mistakes.

Every Monday I'll release new posts. Stay tuned :)

Top comments (0)