Upload
matej-koubik
View
164
Download
1
Embed Size (px)
Citation preview
DOMAIN DRIVENDESIGN
CO JE TO MODEL?
CO JE TO MODEL?(užitečné) zjednodušení "reality"
ARCHITEKTURAWEBOVÉ APLIKACE
UI layer
Application layer
Domain layer
Persistence layer
Storage
CO JE DOMÉNOVÝMODEL?
<?php
namespace App\Model;
class Client extends Entity // ...
„Zygohistomorphic Prepromorphisms“
„Dual Overhead Rate Recovery“
„It's Lupus“
UBIQUITOUSLANGUAGE
anglicky!
platí v nějakém kontextu
VALUE OBJECTAddress
$street Pernerova 53
$city Praha 8
$zipCode 186 00
VALUE OBJECTIMMUTABLE
public function changeZipCode($newZipCode) return new Address( $this>street, $this>city, $newZipCode );
ENTITYVALIDACE
$validator>isValid($person);
$person>isValid();
public function __construct($name) $this>name = $name;
ENTITYANEMIC MODEL
if ($person>getAge() >= 18) $originalName = $person>getOriginalName(); $person>setName($newName); $person>setOriginalName($originalName);
ENTITYANEMIC MODEL
public function rename($newName) if ($this>age < 18) throw new \Exception;
$this>originalName = $this>name; $this>name = $newName;
$person>rename($newName);
ENTITYANEMIC MODEL
AGGREGATE
FACTORYinterface ICustomerFactory /** * @param string $name * @param Address $address * @returns Customer */ function create($name, Address $address);
BOUNDED CONTEXTclass Order extends Entity // ...
class Product extends Entity // ...
BOUNDED CONTEXT
-- Martin Fowler
BOUNDED CONTEXTcore domainsupporting subdomaingeneric subdomain
REPOSITORY$repository = [];$repository[$product>getId()] = $product;
interface IProductsRepository function save(Product $product); // make it explicit!
function getById($id); // return whole aggregate!
function delete($id);
@ChangeTrackingPolicy("DEFERRED_EXPLICIT")
SERVICEstatelesssingletonSRP!
DOMAIN EVENTobjektne commandimmutableobsahuje datamůže implementovat interface
CO SI ZAPAMATOVATmake it explicitdefinujte slovníkrozlišujte kontextvyhněte se anemickému modelu
ZDROJE KE STUDIU
ZDROJE KE STUDIUDomain-Driven Design: Tackling Complexity in the Heart of
Software (Eric Evans)
ZDROJE KE STUDIUImplementing Domain-Driven Design (Vaughn Vernon)
ZDROJE KE STUDIUStackOverflow.comgoogle
DĚKUJI