Git Product home page Git Product logo

ddd-in-php's Introduction

author: Michał Powała
source repository: ddd-in-php

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:

DOMAIIN-DRIVEN DESIGN IN PHP COVER

Book's code snip sets

Domain Driven Design In PHP code snip sets (GitHub)

Mentioned books (I decided to point out)

Entities and surrogate Id

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()
    }
}

Notes

  • 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)

TODO

  • 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.