Or is the two included here?
Reply content:
Or is the two included here?
Personally feel that if the business is not complex, the business logic written in the model layer, C-level only write simple scheduling ...
Once a lot of code and logic written on the C layer, but the reusability is very poor, such as the foreground and the background to invoke a business logic basically similar, written on the C-layer feel very redundant
If the business is complex, you can separate layers to deal with the logic, and the M layer is responsible for the data-related storage.
Mainly see your business and Code code conventions, there is no fixed use, to be flexible to use.
Individual suggest that each model data models correspond to a specific data table, processing a separate data table business, logic is the implementation of the business, in accordance with the business package, so as to facilitate maintenance.
M is the data model, for C, M is the equivalent of a database of a table, only responsible for accessing data, business logic is fully implemented in C, C tells m what number of stored fields, M is responsible for generating and executing the corresponding SQL statement and then report the results to C.
Both are available. You can write the usual operations around the model as a method of the model class, or they can be written as business logic into the controller's action.
I generally write the operation around a single model of the CRUD module directly into the method, so called in multiple controllers (Controller to be responsible for error prompt output), complex transactions involving more than one model, is completely written in the controller.
The business logic is all on the C tier, and the C layer has too many responsibilities, and the C layer calls M and V specifically.