author: Michał Powała
source repository: ddd-in-php
This repository is a study of a book Domain-Driven Design in PHP written by CARLOS BUENOSVINOS, CHRISTIAN SORONELLAS and KEYVAN AKBARY:
Domain Driven Design In PHP code snip sets (GitHub)
- Applying Domain Driven Design Patterns by Jimmy Nilsson
- Introducing Eventstorming by Alberto Brandolini
- NoSQL Distilled: A Brief Guide to the Emerging World of Polyglot Persistence by Pramod J. Sadalag
- Patterns of Enterprise Application Architecture by Martin Fowler
- Enterprise Integration Patterns by Gregor Hohpe and Bobby Woolf
- Building Microservices by Sam Newman
User contains $userId, $email, $password
class DoctrineUser extends User
{
private $surrogateUserId;
public function __construct(UserId $userId, $email, $password) {
parent::__construct($userId, $email, $password);
$this->surrogateUserId = $user->id()
}
}
- Doctrine is an implementation of a
Data Mapper pattern
- I always wondered where validation (assertion) should lay - ASSERTION SHOULD BE ENCLOSED WITHIN PRIVATE SETTER (unless that small ValueObject - don't need setter imho, then)
- Public VS private constructor (named constructor):
- public constructor: if object is created with all needed (necessary) properties provided from outside the class
- private constructor and public static named constructor: if object is created without provided all necessary data (it generates it)
- addictionally it allows (static constructor) to implement constructor method without throwing an event, and in business specific method that is named static constructor you can publish events
- If other bounded context generates ID, necessary is Event Driven architecture
- Constructing an object from plain data such as an array is called hydratation
- "Factories help us keeping the business invariants" [page 177] - read more about factories
- Command buses and message systems are used outside the domain model!!! Domain model only published events but all the rest is handled in app layer or infrastructure layer!
- "AsMartin Fowler said in the PoEAA book, the first law of distributed systems is always:Don’t distribute" ❤️
- on message subscribes run commands to the domain using CommandBus (message subscribers are on infrastructure)
- read more about streams
- read more about redis and elasticsearch
- read about surrogate properties in a context to database
- read about active records (don't like it, but still I need to know more)
- read about
Data Mapper patter
- read about
Unit of Work pattern
- read more about messaging (not publishing itself) events!
- read about invariants in context of aggregates
- read about database mechanism pessimistic and optimistic concurrency control
- read about data-structures, like Sets (repository is an implementation of set)
- read more about data transformers****
- read about aggregates and bounded contexts, how does two different aggregate roots within single context cooperate