Tackling Complexity in the Heart of Software
💚 Alan Tech Talk #23 💚
Tackling Complexity in the Heart of Software
Eric Evans, 2003
😅 ~100 pages vs 560 pages https://www.infoq.com/fr/minibooks/domain-driven-design-quickly
👥 Domain model oriented approach from the domain expert inputs
🛠 Toolbox of tactical and strategic patterns
🔫 Not a silver bullet
🤝 Better understand and communicate with your business experts
🤯 Decrease accidental complexity to focus on business complexity
😎 Master the complexity and improve maintenability
✂️ Separate code that changes frequently from code that is stable
🤝 Build a common and rigorous language between developers and business experts
🥸 As the team better understands their business, it could evolve
😇 You should align your code naming (class, variables, …) with the ubiquitous Language
🤯 The domain
is the problem
😎 The model
is the solution
❌ Not a database model, not a UML model
📚 Object oriented model based on Entity
, ValueObject
and Aggregate
Is an object defined by its identity
Has a lifecycle (created, updated, deleted)
Has attributes that change over time
Let’s define a Contract
Is an object with no identity
Is defined by its immutable attributes
Can be shared between identities
🤫 It’s an immutable dataclass
Let’s introduce a Period
and use it in Contract
Is a cluster of domain objects that can be treated as a single unit (= same transaction)
Has one root entity
All references from other aggregates should reference the root, not the sub entities.
Represents a persistent collection of entities
One repository per root aggregate
Is not a DAO (Data Access Object)
class Companies:
def get_company(company_id) -> Optional[Company]:
pass
def add_company(company) -> uuid:
pass
def remove_company(company_id):
pass
def add_contract_to_company(
company_id, reference, start_date) -> Contract:
company = companies.get_company(company_id)
contract = company.add_contract(reference, start_date)
return contract
def create_contract(
company_id, reference, start_date) -> Contract:
contract = Contract(company_id, reference, start_date)
contracts.add_contract(contract)
return contract
Alistair Cockburn, 2005
🗣 Ubiquitous Langage
👨🏫 Domain Model: Entity
, Value Object
organized by Aggregates
🧳 Repository
to handle collection of root Aggregates
⬢ Hexagonal architecture
to isolate domain model from technical stuff
🍿 DDD and 13280 - Moving towards a product architecture
❓ Do you think we can use some DDD patterns for Alan codebase?