I can not learn MVC, what is it and what is not?

I can’t understand what MVC is, what kind of thinking or programming model I should acquire, so can MVC material instantly “ignite” on my head? If not immediately, then what simple programs / projects should I try first, so that I can apply the neat things that MVC brings to programming.

OOP is intuitive and simpler, the object is around us, and the benefits of reusing code using the OOP paradigm instantly click on anyone. You can talk to someone about OOP in a few minutes and read a few examples and get them. While OOP somehow raises the intuitive aspect of programming, MVC seems to do the opposite. I get negative thoughts that some future employers (or even clients) will look down on me so as not to use MVC technology.

Although I probably get the skin aspect of MVC, but when I try to apply it to my own project, I don't know when to start.

And also some programmers even have diverging views on how to correctly execute MVC.

Take this, for example, from Jeff's post on MVC:

A look is simply how you data, how it is displayed. if you require a subset of some data for example, my opinion is this: model responsibility.

Therefore, perhaps some programmers use MVC, but they somehow inadvertently use View or Controller to retrieve a subset of the data.

Why don't we have a final definition of how and how to execute MVC correctly?

And also, when I look for MVC.NET programs, most of them relate to web programs, not desktop applications, it intrigued me even more. I assume that this is most beneficial for web applications, there are not many problems with mixed presentation (html) and controller (program code) in desktop applications.

+4
source share
9 answers

I like the way Martin Fowler puts it :)

http://martinfowler.com/eaaCatalog/modelViewController.html

.. and http://martinfowler.com/eaaDev/uiArchs.html :

Take Model-View-Controller as an example. It is often called a template, but I do not find it terribly useful to think of it as a template, because it contains many different ideas. Different people reading about MVC in different places take different ideas with them and describe them as “MVC”. If this does not cause enough confusion, you get the effect of misunderstandings MVC, which develop through a system of Chinese whispers.

+4
source

You can start by reading the answers to this question .

+3
source

MVC is great for WebApps. Most WebApps receive data from the database, process it a little and show it to the user. DB is your model level, the controller processes and scans, just emits HTML code.

Some people think that controllers should just get data from the model and submit it to the view, but I think that means the controllers are useless and therefore it’s just an MV programming model :) But I understand them if you use some kind of then processing, you are going to use it more than once, and therefore it is better to do it at the model level, it can be divided between different parts of applications in this way.

You do not need to use MVC applications for desktop computers, in fact I'm not sure if this model will work for huge applications, which are usually desktops. Too often you want to use the "component", that you can submit the same data and get the same user interface from it, but in different parts of the application, but simply leads to copying the code using MVC.

+2
source

I found that the MVC paradigm is often too bloated. A simple model / view (without a controller) is easier to understand and easier to implement.

Most people understand that some class contains data (model) and logic for loading / saving data, while another class shows this data (view). Give him some glue to load the document (something like a document manager), and you're done.

+1
source

A “regular” MVC implementation will have:

  • views - displays data for the end user and gives them user interface objects to interact with the data (but not to process this interaction). Controller
  • - Handles user interaction and manipulates data moving between views and the model.
  • - manages the storage of data and the presentation of this data for the application

A frequent use of the MVC template would be to display HTML / CSS / browser for a portion of the presentation of the web application, the application level in PHP / scripting acting as the controller, and MySQL or a similar database acting as a model (which may or may not have which or ORM structure in front of it).

True, very few people use MVC in this format, and for good reason (in my opinion). Different applications have different needs and design requirements, and it is advantageous to bend templates to the required. These days, MVC seems to describe more use of an environment that isolates application layers than the Model-View-Control pattern.

From the point of view of the employer, what is really looking for (often) is a layer of abstraction and experience arising from the creation of an n-tiered application. There is a fairly significant mental transition that happens when you switch from working in an application that can be divided not only into vertical but also into horizontal layers of objects.

As a note, skinning is just an aspect of one particular level, you can change the data sources at the model level, the methods for managing this data (for example, a new algorithm) at the controller level and roll them out gradually without the need to change other layers.

0
source

Perhaps after the Wikipedia article may refer to other implementations. It has links to MVC implementations as graphical GUIs .

0
source

MVC is a template and it works well with OOP, two are not exceptional - I would say that they are orthogonal. The MVC pattern attempts to separate the display code (V) from the data (M) and the control flow (C).

If you are looking for “MVC.Net,” you will almost certainly get a lot of access to web applications because the ASP.Net MVC framework was recently released, and this is the MVC template application for ASP.Net programming, so it is used for website development . As you think, there is no reason not to apply the template to desktop applications either.

If you find it difficult to work with MVC, I would recommend reading the templates in general to understand how people talk about modeling problems / solutions using templates, and then take a closer look at MVC.

Edit The Fowler link hint, his book Enterprise Application Architectur e Templates is a great place to read on MVC and other templates.

0
source

The MVC paradigm is a way to break an application into three parts: Model, View, and Controller. Initially, MVC was designed to map traditional input, processing, and output roles in the GUI domain.

User input, modeling of the outside world and visual feedback from the user are separated and processed by the objects of the model, viewport and controller. The controller interprets the mouse and keyboard input from the user and maps these user actions to commands that are sent to the model and / or viewport to make the appropriate changes. A model manages one or more data elements, responds to queries about its state, and responds to instructions for changing the state. The viewport controls the rectangular area of ​​the display and is responsible for presenting data to the user through a combination of graphics and text ... read more and more .

0
source

At its core, MVC is just a specific case of separation of problems: one block of code is responsible for data storage, the second block is responsible for data management, and the third takes care of user interaction.

Any of these pieces can be implemented using OO, or not - MVC and OOP are orthogonal. (Although, in my experience, MVC applications and frameworks are more likely to be OO.)

0
source

All Articles