Within a MVC default project where main()
of the application should be localized? Thinking a little I figured it was in the model, because it contains the most "complex" parts of code, but I'm not sure.
Within a MVC default project where main()
of the application should be localized? Thinking a little I figured it was in the model, because it contains the most "complex" parts of code, but I'm not sure.
You are relying on a false premise, that the whole system part has to be either M (model), or C (controller) or V (view).
The main()
case is the most emblematic, it is none of them and is located outside the MVC. In the MVC model, M matches the classes that model your domain, whereas V and C dictate how the user (or some other external system) can manipulate your domain.
The MVC tells you how you organize your model and how it interacts with the outside world (or how the outside world interacts with it). In particular, it dictates that you should not pollute your domain with visualization logic or with flow control logic. And if possible, do not pollute the view with flow control logic or your flow control with display logic. This does not say anything and has no relation to things that do not belong to your domain and do not interact directly with it, such as main()
for example (or a library for writing XML documents that your project uses, if you want a different example).
In addition, code complexity is unrelated to whether or not it is part of the model or not. The MVC proposes to reduce the overall complexity by clearly dividing the three layers, but it says nothing about the complexity of each layer in isolation. In fact, the controller tends to be the most complex layer because it is coupled to both the model and the view.
Finally, main()
typically has the purpose of uploading everything that is needed, which possibly means creating / instantiating the controller and often also the model and the view. Although main()
can create the controller, it is not part of it, since it does not manage the application's data flow. The main()
is also not in the model, since it is not a fundamental part of your domain (and if you put main()
in the model, it would be subverting MVC, since it also creates the controller). Obviously it is not view either.