Model-View-Controller - Which component traditionally processes input / output files?

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

+4
source share
6 answers

Short answer: model layer.

Most forms of storage are part of the model layer (excluding templates and autoloader for the class). In fully implemented mode, you should have a group of objects that directly interact with low-level abstractions (SQL, cache, REST API, noSQL, file system, etc.).

If the application actively reads and writes to the file system (in fact, it can be mounted with the remote memory that you installed via Fuse through the SSH tunnel .. it does not matter), this will be handled by structures that deal with the logic storage. Usually some form of data mapper (it is also believed that repositories , units of work , DAOs and / or some similar structures).

Storage abstraction is usually responsible for storing data and retrieving data in objects. In a large-scale application, this interaction between domain objects and logical storage structures is contained in services to isolate the business logic of the application and the domain from leakage in the presentation layer.

+1
source

MVC typically a presentation-level infrastructure that is at the top of Presentation-based applications. In real enterprise applications, you may have several layers below.

This is usually done in another layer: you can name it as a Business Layer or Service Layer .

+1
source

Like other published ones, you will usually have a Domain / Business Layer / Data Layer layer under your MVC application. If you're looking for some good examples of how to implement such a stack using the Entity Framework, check out the NerdDinner and MVC Music Store examples.

http://www.nerddinner.com/

http://mvcmusicstore.codeplex.com/

+1
source

There is some complexity and a lot of confusion around the โ€œlayersโ€ and architecture patterns. If you are looking for the simplest answer, and for simplicity you decided that each part of your code will lie in one and only one (model, view, or controller), then my answer will be selected Model for you to access the database. The reality is that all architecture patterns are imperfect, and you just need to see what feels right with experience.

+1
source

MVC will only be part of a larger architecture.

Infrastructure issues, such as persistence, are usually handled by some classes / objects outside the MVC triad.

0
source

in mvc there should not be any io disk. if it is, it probably belongs to or near the model, if that is what is saved.

0
source

Source: https://habr.com/ru/post/1444943/


All Articles