What's the best approach to divide model and actions into classes in MVC pattern

前端 未结 2 1307
心在旅途
心在旅途 2020-12-12 03:43

Let\'s say I have a class Employee with a huge amount of fields. And I have a lot of actions related to db with it like CRUD, filter etc.

In MVC patter

2条回答
  •  一整个雨季
    2020-12-12 04:26

    I think that normaly will be if the Model contains only the definition of Model classes with geters and setters and all Business Logic in separate classes - maybe separate layer, you can call them EmployeeActions or maybe better EmployeeManager in such way we keep separated logic from definition. But this is only required when you have complex application. Sometimes introducing any additional layers may add unwanted complexity to the code.

    I think a good answer is: https://softwareengineering.stackexchange.com/a/165470

提交回复
热议问题