lets say i have a BlogPost aggregate root. it holds a List<Comment>
.
how should the BlogPost AddComment signature look? is it OK to use:
public void AddComment(Comment comment)
{
Comments.Add(comment);
}
or should i avoid creating references to root's children outside of it, and do something like this:
public void AddComment(string text, string email)
{
Comment comment = new Comment(text, email);
Comments.Add(comment);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…