Here's the classic example:
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public List<Post> Posts { get; set; }
}
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public Blog Blog { get; set; }
}
This creates a circular (or cyclic) dependency. And as such, you get all the nasties that come with circular dependencies: Single Responsibility violation, JSON serialiser exceptions, and IoC container exceptions, to name a few.
It very much feels like a code-smell.
Is it?
Aucun commentaire:
Enregistrer un commentaire