The question how-do-you-organize-your-projects already has a few good answers. I would like to get a better understanding about this suggested structure:
MyApp.Core
MyApp.Model
MyApp.Presenter
MyApp.Persistence
MyApp.UI
MyApp.Validation
MyApp.Report
MyApp.Web
Assuming MyApp
is a winforms rich client to administer students, courses, rooms and teachers
Lets say i have a winforms user control to edit course information (name of the course, who teaches it, in which room and which students did register for the course). The class below reflects all the information i need for the user control
public class CourseDetails{
public int Id{ get; set;}
public Course Course{ get; set;}
public Teacher Teacher{get; set;}
public Room Room{get; set;}
public List<Student> StudentList{get; set;}
}
Where would you put this class?
Methods of MyApp.Model
I would like to know how complex or simple the classes inside the namespace MyApp.Model
shoud be.
Should the project MyApp.Model
only contain very simple classes like
public class Course{
public int CourseId{ get; set;}
public string CourseName{ get; set;}
public int CategoryId {get; private set;}
}
public class Teacher{
public int TeacherId{ get; set;}
public string TeacherName{ get; set;}
}
or should MyApp.Model
contain also
- complex classes like
CourseDetails
- additional methods for each class like
Save()
orGetById()
?
Additional topics
Where (in which project) should interfaces be implemented and where should base classe be used.
When should this additional methods (Save()
, GetById()
) be inherited from a base class or be contained in the class which implents an interface that has all the methods for saving and selecting.
public class CourseDetails: ModelBase{
...
}
public class ModelBase{
public bool Save() {
Console.WriteLine("do something clever to save each entity");
return true;
}
}
Sorry for not beeing more clear; I would like to understand what kind of things (classes, interfaces, ressources, etc) should be put in which project and why. I hope you get the idea.