Answer the question
In order to leave comments, you need to log in
MVC: where to store and create views?
In large applications there are many different views, what is the right way to store them? Create a separate MainView class that will store links to all views? Or store each link separately in the controller?
Same question about models
Answer the question
In order to leave comments, you need to log in
What MVC are we talking about now? there are many different ones. From your question, for example, we can conclude that there are two options.
This is reminiscent of MVC from 1979. In this case controllers are only concerned with processing user input. And everything that concerns the presentation is handled by the View itself. The view here is active, it has a lot of logic and it happens that there is even more of this logic than in the model. In our example, this will be the same MainView that will work directly with the model and take the necessary state from it and update itself according to changes (or ButtonView - it depends on what we want to present. The MVC description does not make any restrictions on how much you can have these gizmos on the screen).
It's more like a mediating controller MVC. This approach was invented in order to remove the dependence of the view on the model. In fact, the view becomes passive. Now the controller decides when to update it and how to render it at all.
So decide what you need. I suspect that the second is still because no one has been actively using the first for 20 years.
You umm...
In short. See how it works in other MVC frameworks. For example in laravel
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question