[TYPO3-dev] The extbase dilemma

Franz Koch typo3.RemoveForMessage at elements-net.de
Sat May 21 00:40:19 CEST 2011


Hey Mathias,

> If we stick to the blog example:
> 100 blogs with 100 posts each and 100 comments per post.
> You want to display the latest comment per blog.
> IIRC this would result in at least 100 queries, right?

as Peter mentioned this is a good example. Doing it the pure DDD way and 
only have blogs as aggregate roots you would end up with your 
assumption, because you would have to iterate all the way down to the 
desired comments. Nobody with at least some brain would ever do that, 
would he?

In those cases I also leave the "perfect" DDD approaches. Although 
someone once stated that only aggregate roots should/must have a 
repository, I can't second that - it's not doable in real world unless 
you only have a dumb extension to code or a google server farm at hand. 
Nobody would/can create tag clouds etc. in a clean DDD way (iterating) 
without bumping the world climate by 0.001°C. So in this case I'd 
probably create a repository for the comments and simply query for the 
latest comments -> 1 query -> done.
Depending on your preferences you can do this in the controller, or you 
could add a method "getLatestComments" to the blog model and internally 
trigger the repository and directly return the queryResultObject. Moving 
it inside the blog object is of course only useful if you like to 
display the comments grouped by blog while having full control of the 
rendering inside the view (setting the result limit using a widget, add 
pagination etc) - otherwise just query for the comments directly in the 
controller, assign it to the view, done.


-- 
kind regards,
Franz Koch




More information about the TYPO3-dev mailing list