Closed wazum closed 2 years ago
Thanks for attending and for taking the time to open this discussion instead of just bashing live.
About 1, I agree it does not make sense in a real world project. A proper way to update an existing entity should be added.
Regarding 2, these properties should definitely be immutable. If it’s not the case now, then that should be fixed.
Indeed, that repository is only an API Platform integration example, it isn't intended to be a DDD/Hexagonal best practice example!
But both of your observations are great IMHO. Therefore we must handle them, and feel free to contribute if you want to! 😉
PR welcome!
Thanks for the example and the presentation, but as this should be an example project for best practices(?), allow me to ask some questions:
But remove the complete book and then add it again.
Why would you do that?
And despite telling me in the Chat on the API platform conference that they are readonly, they are not. You even use this fact in the above-mentioned command handler:
which contradicts ideas DDD stands for. You don't want to modify single (public) properties and expose the object to the risk of entering an invalid state! The correct way to do this update is through a single public method that updates all (private/protected) properties at once (and checks some rules).