Domain Modeling Kata

While developing the first MozaicLabs product, eventrix.co, we wanted to use our full experience in agile, lean and software craft. Here’s a list of things we’ve adopted:

  • A kanban process to have a steady flow of features and to allow improvements
  • A technical strategy
  • Continuous delivery and automated testing from day 1
  • Impact mapping to create a development strategy
  • Story mapping to slice features and to understand our progress
  • BDD to clarify features before starting developing.
  • Domain modeling as an important part of the design process, to reduce waste caused by lack of domain understanding.

Then, we started innovating by introducing design elements to preserve consistency of software design. We realized at some point that the team needed more experience with domain modeling and created a new practice format: a domain modeling kata.

Domain Driven Design

Domain Driven Design, or DDD, is a mindset for software design and a set of patterns that support it. The idea is to “tackle the complexity at the core of software” by clearly identifying the domain of the problem and the relations between domain entities.

Like anything related to design, DDD is hard. It requires a lot of experience, practice, and skill. Practitioners need to be very careful with nuances and iteratively work through the domain model until it’s quasi-correct. This is probably why subsets of DDD evolved, with more specific constraints: CQRS, event sourcing etc.

At the core of DDD are understanding and modeling the business domain.

Problem

Our kanban process allows us to notice when things take longer than expected and adapt the process to the new reality. We noticed that we had to add tasks to change the domain model. These tasks took up to 10 days, much longer than our usual 2-3 days cycle time. They fit in what’s called “failure demand” in lean / kanban (doing something again because you haven’t done it right the first time). This delay was due to other factors as well, like learning how to write schema migrations at the same time with implementation. But the root cause seemed to be a lack of understanding of the domain model.

As lean thinkers, we asked ourselves: what can we change in the process to make things better? The solution was to add a domain modeling step to the design process, to be done whenever working on new features. Being a new skill, we realized that the team needed more practice. Obtaining good domain models is not trivial.

And this took us to the next step: practicing domain modeling. That’s when our years of experience with software craftsman training paid off. We immediately thought about using a kata format for practicing domain modeling.

Solution

For those who haven’t heard of it: a coding kata is a repeatable exercise that involves writing code within certain constraints for a fixed period of time and then making a retrospective on the session. Typical coding kata examples are:

  • computing the bowling score by using Test Driven Development (TDD)
  • refactoring a code base that’s already covered with tests
  • adding tests to very messy code

A typical time limit is 30′-45′, but it can be longer depending on the problem. Coding katas can be done alone, in a pair or in a group where more pairs write code and compare results. Other similar formats like coding dojo and code retreats emerged from similar ideas. The retrospective is the moment when the programmers reflect on things like What went well? What was difficult to do? What can be done differently next time? etc.

The domain modeling kata applies the same line of thinking.

The Format

The domain modeling kata starts by setting a few things:

  • The timebox: we tried around 2hrs, but it depends on the group and the domain complexity
  • The problem: we tried “a tool for kanban” and “a saboteur game” and a few core features (e.g. for kanban: create a board with columns and swimlanes, add work items, advance work items, create cycle time distribution report). The problem has to be from a domain well understood by the participants
  • The tools: it’s important to be easy to erase and move things around. Stick post-its on a surface or use a whiteboard for each group. We recommend against using digital tools because they impede collaboration in the group (one person will be at the keyboard, instead of everyone writing on post-its)
  • What we’ll do: we’ll create a domain model for this problem, meaning domain entities, relationships, bounded contexts and constraints

Split into groups of 2-4 people. Using the tools, create a domain model using the following steps:

  • Brainstorm domain entities
  • Add relationships
  • Add bounded contexts
  • Add constraints (e.g. invariants)
  • Review the model using the core features requested

This process is not linear. When adding relationships, you’ll probably discover that one domain entity is actually a combination of domain entities. When adding bounded contexts, you might need to duplicate domain entities. etc.

At the end, we do a retrospective, in two parts. The first part is showing and tells: each group will walk us through their domain model and the other groups ask questions. The second part is looking back at the process. Open questions help; here are some examples:

  • What was difficult to do and why?
  • What surprised you?
  • What did you discover during the process?
  • How would you apply this at work?

The Results

We’ve done this three times recently: twice in the company and once at SoCraTes. During the SoCraTes practice, the attendees enjoyed it. Here are a few learnings:

  • identifying the bounded contexts is the hardest part
  • using functional use cases as starting point helps with the bounded contexts
  • this exercise can be used to develop a common language between the development team and the business team
  • when doing the kata with multiple groups for the same domain, there will be big differences between models of each group

In the pictures bellow, you can see the differences between 3 models of Slack application domain, done by 3 groups at Socrates.

ddd_slacapp_model_group1
ddd_slacapp_model_group2
ddd_slacapp_model_group3

It needs experimentation before it can be widely used. Some recommendations to implement it yourself are:

  • try more problems until you find a set that is easily understood by most developers
  • run it with different groups and document the results (including impediments)
  • clarify each step of the kata

Conclusion

Domain modeling is a software design practice that cuts down failure demand from software development. At the same time, it’s a new skill for many developers. Using a kata format to practice this skill proved very beneficial for developers. However, the format needs more experimentation to become widespread.

Will you run a domain modeling kata in your team, company or community? Why? Why not? Let us know in the comments.

More from the Blog

3 thoughts on “Domain Modeling Kata”

  1. This article was so confusing to me. I was looking for domain-modeling katas and i think this is just an article. I was thinking perhaps you were going to provide something or a link to what you did or the katas you created but there seemed to be thing here. It’s quite confusing. There are not links or anything you can provide us to learn domain modeling. There doesn’t seem to be training on this as well. The post really don’t tell you the purpose. It just dives in.

    1. Alexandru Bolboaca

      Hi Jacob! Thank you for your feedback, it’s very useful to us to know when an article is unclear, confusing or can be improved.

      I would like to understand better what you were looking for, in order to improve the article or write another one more focused on your needs.

      Just to provide some context, the article was written considering people who know the basics of Domain Driven Design and who know a bit about what a kata is. The section called “The Format” explains how to experiment with this exercise. I understand this wasn’t helpful for you, so what would have been helpful?

      As for training options, we often create customized trainings; if you need something like this please don’t hesitate to contact my colleagues here: https://mozaicworks.com/contact/.

      Thank you again for your feedback, and let’s find a way to help you.

      Cheers!

Leave a Comment

Your email address will not be published. Required fields are marked *

0
    0
    Your Cart
    Your cart is empty
      Apply Coupon
      Available Coupons
      individualcspo102022 Get 87.00 off
      Unavailable Coupons
      aniscppeurope2022 Get 20.00 off
      Scroll to Top