jeudi 18 février 2021

Onion Architecture Entity Relationships

I'm playing with the Onion Architecture and I got a bit confused about how the Domain Entities are designed.

Let's say I have a chat application that has Post, Comment entities.

The domain entities I imagine would look like this:

class Post {
  id: string;
  text: string;
  comments: Comment[];
}

class Comment {
  id: string;
  text: string;
  post: Post;
}

So this gave me a few questions:

  1. Is it correct to define relationships in the domain entities?
  2. Or is it better to not have any relationships in the domain entities?
  3. Where should I implement the postComment / createPost methods and what arguments will they accept?

Aucun commentaire:

Enregistrer un commentaire