[TYPO3-50-general] FLOW3 Sample Blog Application Aggregate Roots Clarification

Nino Martincevic don at zampano.com
Tue Aug 18 10:44:23 CEST 2009


Hi Duo!

Duo Zheng wrote:
> In the Blog Application, Blog, and Post are Aggregate Roots as they  
> both have Repositories. I believe I am modeling this wrong, but is it  
> correct to have Post as an Aggregate Root when Blog already is?
> 
> When a Blog is deleted all its entities are deleted with it. You can't  
> have a Post without a Blog so it "seems" correct for Blog to be the  
> only Aggregate Root and post to be part of that Aggregate.

Don't think structural but conceptional, in use cases and business 
(domain logic) requirements.

Btw: Why can't a post being moved to another blog or stay as it is?
:-)

But read further...

> I guess to clearly ask the question and getting straight to the point,  
> can you have Post be an Aggregate Root by itself in one case and just  
> an Entity in another?

Yes.
As above, limiting objects to structural classes is not OOP but COP...

An object being part of an AR in one case and the AR itself in another 
is pure valid and clean. It depends on your use cases which ARs you 
have. And that determines the context for each AR.

But there is no general guidance, it depends on your domain.
As said, most important is not to limit e.g. Post being just an entity 
(by say implementing IEntity).

In your example it's not quite clear what the Blog AR does?
The Blog is the whole application, isn't it?

Without the application, Posts wouldn't have much sense, that's true.

The Blog aplication in fact is a very poor example for Domain modelling, 
because it's almost only a CRUD app.

And DDD isn't suited very well for CRUD, in fact you should better avoid 
it there. It complicates things, and all the necessary stuff you need 
for CRUD, your ORM already offers it.

Hope that helps.




More information about the TYPO3-project-5_0-general mailing list