Where should the business rule stay in the MVC standard?
If there really is business logic, and especially if it is complex, it should stay in Model .
The concern that the creation of the MVC pattern (there in the 1970s) tried to solve is the separation between presentation and business logic, and the controller is mostly coupled with the presentation .
See this Fowler drawing for MVC :
NoticethatViewknowstheController,whichalsoknowsView;andnoticethatModeldoesnotknowanyone.
Inhisbook Patterns of Enterprise Application Architecture , Fowler says:
"The separation between presentation and model is one of the most fundamental heuristics of good software design."
In this same book, he mentions that the separation between Controller and View may not be so obvious in many designs , and that this is not a problem,
And they are even confused: note how the Controller really needs to know View, he knows the presentation rules (he is also the one who defines these rules).
This intimacy between Controller and View is already an indication that the Controller is not good company for business logic (tell me who you walk with and I'll tell you who you are) if you really want to separate these concepts.
But what, after all, is "logic" or "rule" of business?
StackOverflow needs to show the answers with the most votes first. Is this a business rule? Certainly it is, this is a core principle of the tool.
StackOverflow can not support an untitled question. This is also a business rule.
So these rules need to be in the Model? They do not need and probably are not. These are very simple business rules that can be resolved in the presentation.
OS, such an important tool with so many users, may not even have a domain layer concentrating its business rules with high abstraction. It is possible that Models here are just DTOs representing the data in the database.
The SO is probably an example of a system that is classified as low-complexity business rules, where abstraction of the domain in a layer may be unnecessary and even harmful.
Most of the projects I've attended to date, however, had complex enough business rules and a need for reuse that warranted a more elaborate design approach. But with absolute certainty not all systems justify such an approach! I will not talk about "majority" in general because I do not have statistical data. I can only speak from my own context.
If you decide, my child: the rules may or may not stay in the Controller?
If the system has simple rules, basically rules of presentation.
Should not have complex rules, a complex domain, and high need for reuse (rules need to be available for more than one type of consumer - such as end user, service fronts, other system services , integrations, code bases of other systems, etc.).
I'll leave the answer with Fowler (removed from the book already mentioned):
"The value of MVC lies in its two separations. Of these, the separation between presentation and model is one of the most important principles of software design, and the only time you should not follow it is in very simple systems where the model has no real behavior in it.
As soon as you have some non-visual logic, you should apply the separation.
Unfortunately, a lot of UI frameworks make this separation difficult, and those that do not become almost always taught without separation.
The separation between view and controller is less important so I would only recommend doing it when it is really useful.