Closed tworzenieweb closed 8 years ago
None, I was trying to add in the same application both examples of User and Wish conforming and not conforming an aggregate in order to explain the design differences. But it's WIP.
2016-04-18 8:36 GMT+02:00 Łukasz Adamczewski notifications@github.com:
In User aggregate there are two different methods for creating wishes. What are the use cases for each?
As I guess the first one is perfect for persisting as a single.
public function makeWishNotBeingAnAggregate(WishId $wishId, $address, $content) { $newWish = new Wish( $wishId, $this->id(), $address, $content ); DomainEventPublisher::instance()->publish( new WishWasMade( $newWish->id(), $newWish->userId(), $newWish->address(), $newWish->content() ) ); return $newWish; } public function makeWish(WishId $wishId, $address, $content) { if (count($this->wishes) >= self::MAX_WISHES) { throw new NoMoreWishesAllowedException(); } $this->wishes[] = new Wish( $wishId, $this->id(), $address, $content ); }
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/dddinphp/last-wishes/issues/10
Carlos Buenosvinos Zamora carlos.buenosvinos@gmail.com 659730605
url: http://carlosbuenosvinos.com twitter: buenosvinos skype: carlos.buenosvinos gtalk: carlos.buenosvinos@gmail.com
In User aggregate there are two different methods for creating wishes. What are the use cases for each?
As I guess the first one is perfect for persisting as a single.