Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Model-View-Controller - Which component traditionally handles file I/O?

In a traditional MVC application, which component (model, view, or controller) is responsible for reading/writing the model to/from disk?

like image 736
weberc2 Avatar asked Nov 08 '12 21:11

weberc2


People also ask

What are the main components of the Model-View-Controller?

The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application.

What are the three 3 parts of Model-View-Controller pattern?

-MVC is an architectural pattern consisting of three parts: Model, View, Controller. Model: Handles data logic. View: It displays the information from the model to the user. Controller: It controls the data flow into a model object and updates the view whenever data changes.

What does the controller do in Model-View-Controller?

A controller is responsible for controlling the way that a user interacts with an MVC application. A controller contains the flow control logic for an ASP.NET MVC application. A controller determines what response to send back to a user when a user makes a browser request.

Is controller responsible for providing the user interface UI to the user?

Controllers are the components that handle user interaction, work with the model, and ultimately select a view to render that displays UI. In an MVC application, the view only displays information; the controller handles and responds to user input and interaction.


2 Answers

Short answer: model layer.

Most of the forms of storage are part of model layer (with exception of templates and autoloader for class). In a fully realized mode layer you would have a group of objects which are directly interacting with low level storage (SQL, cache, REST API, noSQL, file system, etc. ) abstractions.

If you application is actively reading and writing to the filesystem (it could be actually mounted remote MemoryFS, which you mounted via Fuse through SSH tunnel .. it does not matter), this would be handled by structures, which deal with storage logic. Usually some form of data mapper (thought it also might be repositories, units of work, DAOs and/or some similar structures).

The storage abstraction are usually responsible for storing data from and retrieving data into the domain objects. In a large scale application this interaction between domain objects and storage logic structures is contained within services to isolate the application and domain business logic from leaking in the presentation layer.

like image 197
tereško Avatar answered Nov 24 '22 14:11

tereško


MVC is typically a presentation layer framework, which comes at the top in Presentation based applications. In real enterprise applications, you may have several layers below it.

Typically this is done in another layer: You may name it as Business Layer or Service Layer.

like image 34
Yogendra Singh Avatar answered Nov 24 '22 15:11

Yogendra Singh