I have a problem with entity design. As I read, when you create a DDD object, the constructor should contain the values necessary for the entity to exist. For example, in the domain I'm working on, a class object cannot exist without a section and level:
public class Class
{
public Class(short id, string section, Level level)
{
ID = id;
Section = section;
Level = level;
}
public short ID { get; private set; }
public string Section { get; private set; }
public Level Level { get; private set; }
public static IList<Class> GetClassesByTeacher(short teacherID)
{
List<Class> classes = new List<Class>();
classes.Add(new Class(1, "a", null));
classes.Add(new Class(2, "b", null));
classes.Add(new Class(3, "c", null));
return classes;
}
}
Here Level is also an entity. Since I am not finished in design, the Level contructor may also contain the SchoolYear entity. I am concerned about calling the GetClassesByTeacher method, I need to create an instance of the class along with other objects (Level, as well as SchoolYear, necessary in the level constructor).
? , , . ? , , , . , CQRS , , , , - , CQRS, , DDD, ? ?