我是n层应用程序的新手,我需要一些帮助来启动和组织此类应用程序的结构。我已经阅读了一些关于这种设计优点的文章和博客,我意识到它很复杂但值得学习。最后,我的目标是将DI用于可维护性和更容易的测试。
这可能听起来微不足道但是我发现的第一个问题是我应该遵循模块化结构的任何约定来正确地委托逻辑和功能,然后根据它们的目的命名这些模块的惯例是什么。我确实尝试自己开始,但我很难找到(1)应用程序的正确结构,以及(2)哪个对象应属于哪个模块。
我以为我可以从一个相对简单的测试开始。我想到的项目是一个经典项目,由几个表组成,如学生,模块,部门,教师。可能的查询:
表格:学生,单元,教师,部门
功能:
我还尝试创建一个基本的n层结构,包括这些层:Presentation,BusinessLogic,DataAccess和Data。我不知道我是否正确行事。这是我第一次开始与n层应用程序和DI相关的任何事情,所以请耐心等待。此外,我将非常感谢任何评论。
结构:
+ Presentation (Root Layer)
+---- HomeController
+---- DepartmentController
+-------- DisplayList
+---- StudentController
+-------- DispayList
+---- ModuleController
+-------- DisplayList
+ BusinessLogic (Middle Layer)
+---- MapObject
+-------- MapStudent2StudentVM
+-------- MapDepartment2DepartmentVM
+-------- MapModule2ModuleVM
+---- Repositories
+-------- Students
+------------ CRUD
+------------ ReturnList including grouping, filtering, ordering
+-------- Modules
+------------ CRUD
+------------ ReturnList including grouping, filtering, ordering
+-------- Departments
+------------ CRUD
+------------ ReturnList including grouping, filtering, ordering
+---- Services
+-------- Students
+------------ GetListOfStudents
+------------ CalculateAverageScore
+------------ GetTopXStudents
+-------- Modules
+------------ GetListOfModules
+------------ GetModulesPerDepartment
+------------ GetListOfStudentsPerModule
+-------- Teacher
+------------ GetListOfTeachersPerDepartment
+------------ GetListOfStudentsPerTeacher
+-------- Departments
+------------ GetListOfDepartments
+------------ GetStudentAverageScorePerDepartment
+-------- Calculations
+------------ CalculateAverage
+------------ FindMaximum
+ DataAccess (Bottom Layer)
+---- DataContext
+-------- ObjectDefinition (OnModelCreation)
+-------- Configuration
+------------ StudentEntityConfiguration
+------------ DepartmentEntityConfiguration
+------------ ModuleEntityConfiguration
+-------- Seed
+------------ LookUpsForDepartment
+------------ LookUpsForModules
+------------ LookUpsForStudents
+ Data (not in Code First)
+---- < Code First design >