dddshelf / last-wishes

Last Wishes is a PHP application written following Domain-Driven Design approach. It's one of the sample applications where you can check the concepts explained in the "Domain-Driven Design in PHP" book.
https://leanpub.com/ddd-in-php
660 stars 121 forks source link

makeWishNoAggregateVersion misses no more than 3 wishes business rule #21

Closed permiakov closed 5 years ago

permiakov commented 6 years ago

Hi guys. Thanks for the book.

I am wandering where it would be placed "no more than 3 wishes business rule" in case of makeWishNoAggregateVersion?

tszymanek commented 6 years ago

If it's a business rule, it should stick to the domain layer as close as possible. There's no other option to tell how many Wishes a User has.

You could try to make WishRepository an abstract class and place a const there and compare the number of Wishes with given UserId with it, but it becomes less clear what your domain constraints invariants are and where to find them.