
Domain-Driven Design (DDD) is an approach to software development where the code is structured around the business domain rather than technical layers. Instead of starting with the database or framework, you start with the problem the business is trying to solve — and let that shape the architecture.
For this dev meeting, Mateusz Kubaszek — consultant, software architect, and data engineering architect — walked us through the core concepts with Python examples.
Here's what DDD looks like applied to a music distribution platform:
# Value Object — defined by its attributes, no identity
class ISRC:
def __init__(self, code: str):
if not self._validate(code):
raise ValueError(f"Invalid ISRC: {code}")
self.code = code
@staticmethod
def _validate(code: str) -> bool:
return len(code) == 12 and code[:2].isalpha()
def __eq__(self, other):
return isinstance(other, ISRC) and self.code == other.code
# Entity — has identity (id), mutable state
class Track:
def __init__(self, track_id: str, title: str, isrc: ISRC, duration_seconds: int):
self.track_id = track_id
self.title = title
self.isrc = isrc
self.duration_seconds = duration_seconds
# Aggregate Root — controls access to child entities
class Release:
def __init__(self, release_id: str, title: str, artist: str):
self.release_id = release_id
self.title = title
self.artist = artist
self._tracks: list[Track] = []
def add_track(self, track: Track):
if any(t.isrc == track.isrc for t in self._tracks):
raise ValueError(f"Track with ISRC {track.isrc.code} already exists")
self._tracks.append(track)
@property
def total_duration(self) -> int:
return sum(t.duration_seconds for t in self._tracks)
Release has Tracks, a Track has an ISRC. The ubiquitous language is embedded directly in the code.DDD is not for every project. It adds upfront complexity that pays off in large, evolving systems with complex business rules. A simple CRUD app doesn't need it.
DDD works best when:
Mateusz Kubaszek is a consultant, software architect, and data engineering architect with deep experience designing complex technical solutions. His presentation included live Python examples showing DDD patterns in practice.
Building something similar or facing technical challenges? We've been there.
Let's talk — no sales pitch, just honest engineering advice.
D-Commerce Decoded: Cutting Through the Hype
What is d-commerce exactly? It's the evolving realm of digital commerce, specifically focused on the trading of digital goods and services.
Dev Meeting 003: Web3 Primer
A primer on Web3 fundamentals. Learn how network interactions are evolving and why companies are adopting Web3 elements in their projects.
Technical Partner
Technical partner at MusicTech Lab with 15+ years in software development. Builder, problem solver, blues guitarist, long-distance swimmer, and cyclist.
Get music tech insights, case studies, and industry news delivered to your inbox.