I was learning about DDD recently and didn't quite understand the concepts. I have some questions about a sample blog application.
Let's assume that there are four domain objects in the blog system: User
, Blog
, Post
and Comment
. One User
can have only one Blog
, a Blog
has multiple Post
entities and a Post
has many Comment
entities.
My design is that Blog
is the aggregate root:
class Blog {
private User;
private List<Post> posts;
}
class Post {
private List<Comment> comments;
}
class BlogRepository {
public void saveBlog(Blog blog);
public void findBlogById(long id);
public void getAllBlogs();
}
Am I right to design the aggregate root and repository like this?
I have some requirements to get all the Comment
entities added by an user for all Blog
entities, and also the User
is allowed to modify her/his own Comment
.
My question is how can I implement these requirements?