Introduction to Domain Driven Design (Webtlak #7)

Preview:

Citation preview

Introduction to DDD

Adam Štipák | @new_POPE | rekurzia.sk

Who I am?

Adam Štipák@new_POPE

rekurzia.sk

● since 2006

● Sven Creative

● Sygic

● Diagnose.me

● and other “secret” projects

What is DDD?

“is an approach to software development for complex needs by connecting the implementation to an evolving model”

- wikipedia.org

● Useful and meaningful model of its Domain

● Domain Experts contribute to software design

● Better user experience

● Clear boundaries

● Better architecture organization

● Iterative and continuous modeling in an Agile fashion

● better tools, both strategic and tactical design

Why DDD?

Architectural styles - old layered architecture

Architectural styles - MVC

Architectural styles - Hexagonal architecture

The dependecy inversion principle

“High-level modules should not depend on low-level modules. Both should depend on abstractions.

Abstractions should not depend on details. Details should depend on abstractions.”

- Robert C. Martin

Ubiquitous language

“When we recieve a new order, system sends a

notification”

Ubiquitous language

What is the new order?

Bounded context

Building blocks

Value Objects

● Immutable

● “comparable”

Entities

● Identifiable

● Consistent

● Avoid ANEMIC MODEL

○ setSong(newSong)

○ replaceSong(newSong)

Aggregates

● lists, maps, etc

● order, clinic visit, playlist

is a cluster of domain objects that can be treated as a single unit.

… says Martin Fowler

Factories

● creates something

● create(...)

Repositories

● Collection oriented

○ get(ID), add(), addAll(), remove()

● Persistent oriented

○ get(ID), save(), saveAll(), ...

Services

● stateless

● singleton (not Singleton pattern)

○ e.g. ne instance in DI container

● SRP!

Domain Events

● contains data

● immutable

E.g.

● born

● song replaced

● song on cassette was cleared

Resources

● The blue book● The red book

● Domain Driven Design Quickly● Domain-Driven Design in PHP

???Questions ???Adam Štipák | @new_POPE | rekurzia.sk

Thank you!Adam Štipák | @new_POPE | rekurzia.sk

Recommended