Any suggestions on clean ways to solve this design issue?
public class Task
{
public User Assignee
public User Assigner
}
public class User
{
public string Name
}
So a task has two users. But now we want to add support for groups…
public class Group
{
public string Name
public IEnumberable<User> Users
}
And we want the task to be able to handle a group as an Assignee
public class Task
{
public User/Group Assignee
public User Assigner
}
When I think about inheritance here. Group “is a type of” User doesn’t meet this LSP because Group “is not replaceable by” User
I’m using Entity Framework (model first).
Groupis notUser. That is incorrect modelling. If you need inheritance define a new top level abstract entity – for exampleIdentityand deriveUserandGroupfrom this entity: