alexeyzimarev/ddd-book

Why does the Picture entity in Chapter 7 not raise a create event?

jezzsantos opened this issue · 1 comments

I notice that when you create a picture in the Ad: https://github.com/alexeyzimarev/ddd-book/blob/master/chapter07/Marketplace.Domain/ClassifiedAd.cs#L63 it raises the Events.PictureAddedToAClassifiedAd which I understand.

However, in the ctor of Picture https://github.com/alexeyzimarev/ddd-book/blob/master/chapter07/Marketplace.Domain/Picture.cs#L6 it does NOT raise any create event.

But ClassifiedAd raises a create event when it is created. https://github.com/alexeyzimarev/ddd-book/blob/master/chapter07/Marketplace.Domain/ClassifiedAd.cs#L23

Is that because only Aggregate Roots raise create events? or should all entities, and aggregates raise create events?

It's because pictures don't add themselves, it's the ad as an aggregate root to control its child entities. When it comes to the logic that is specific to the picture entity, then that behaviour is implemented inside the entity itself.