Contents
What should the model do in a MVC application?
The Model should handle data access. Models. Model objects are the parts of the application that implement the logic for the application’s data domain. Often, model objects retrieve and store model state in a database.
What do you need to know about MVC architecture?
MVC is known as an architectural pattern, which embodies three parts Model, View and Controller, or to be more exact it divides the application into three logical parts: the model part, the view and the controller. It was used for desktop graphical user interfaces but nowadays is used in designing mobile apps and web apps.
Are there any misconceptions about MVC design?
It was perfect solution for initial goal, but, when it started to spread in other areas, introduced large number of misconceptions about MVC and MVC-inspired design patterns, like “view is just a template” and “model is ORM”.
What should the controller or the model do?
Controller – bridge between the model and view. Decides where to go next. Model – business logic, interface to data store. One of the biggest gains is in maintenance and (later) expansion. In general: If you need to change business logic, you should not need to modify your controller or view.
Which is responsible for data access in MVC?
For example, a Product object might retrieve information from a database, operate on it, and then write updated information back to a Products table in a SQL Server database. In MVC, the model is responsible for handling data access. The pro is that all data access code is encapsulated logically by the model.
How is a MVC used in a desktop application?
MVC was originally defined to ease the programming of desktop applications. The view subscribed to model events, updating the presentation when the model changed. The controller merely translated user interface events (e.g. a button press) into calls to the model. So the controller and view depended on the model, but were independent of each other.