Ddd is not for developing a blog
I understand you’re trying to exercise the concept, but a blog is not a good context to exercise DDD because a blog is too simple a domain - it does not offer the kind of complexity that DDD seeks to solve.
If we insist on using DDD on a blog, we’ll realize that comments are not entities but yes valuables because a comment has no identity and has no relevance in the domain if it is not preceded by the post.
This put; yes, in DDD the correct way to get comments would be through a post method (the getComentarios that you mentioned).
But I repeat: this is not a valid example of DDD.
Using DDD to develop a blog brings more problem than solution
See the kind of problem you face trying to use DDD in this case:
When a post is very successful and receives 900 comments, getComenters will become a slow method and the rendering of a page with 900 comments at once will also be too slow.
If you want to implement paging in getComenters, you need to do this in another layer (in the application or below) because according to the DDD this implementation detail can not obfuscate the domain code.
This would take a lot more work than simply implementing paging by getting comments directly from a repository, a DAO or even directly from the database (all of which would seriously hurt the principles of the DDD).
And this additional work would bring no benefit because as Post and Comments are very simple artifacts, they will not enjoy the benefits of such careful abstraction.
Yes, I agree with you. In my question I only used to exemplify, I’m not using Ddds for a blog, I’m using them for a system that actually has business rules and tends to grow a lot. But you touched on an important point, which is the question of performance, mainly in web systems. Thank you for the answer.
– Rodrigo Otavio