What is the View in the MVC standard?

28

I started in 2016 to use MVC standard, the concept of Model and Controller perfectly understand, / em> intrigues me.

What is the View in an MVC template?

I know what the client sees (data representation) , but what can be understood as part of a View ?

And in the case of a separate application for the client interface, can I consider this as the View layer?

In other words: What is part of View on the server side talking in Web development?     

asked by anonymous 28.11.2016 / 12:42

2 answers

21
  

What is the View in an MVC template?

View is the presentation of data, it is the output, it is how the user will see what was produced by an action of the application, and is how a data entry will occur and initiate a action by the user.

MVC does not assume that it uses a client-server architecture , so using these terms does not make sense unless the MVC is being used in a web application with this architecture. MVC can even be applied only from the client side, and technically when it is used on the server side it is all on the server, after all the view is just the creation of the HTML page. Even if the context is this, using the words "client" and "server" is something punctual and has nothing to do with the pattern.

So the separation of the layers in different instances of the solution is possible, because the model can be in one server, the controller can be in another, the vision generator can be in another, just as the renderer of this vision can be in another device (it can be a client).

There is nothing that determines that it should generate HTML, XML, JSON, or something like . It can generate a proprietary form of communication, something like a black box that only matters to that application.

  

What can be understood as part of a View?

It is often the mechanism that determines what will be rendered to the client, but is not usually the rendering engine (effective design). So it has mainly what will be presented, with what characteristics and how the user should interact with it.

It is common to have some logic of application and business rules, mainly application and mechanisms of contact with other layers. What is recommended is to minimize all of this and leave as much as you can give only the presentation. Of course not at the cost of harming the user experience.

View may communicate with model , nothing in the standard dictates that this is prohibited. It is common to avoid this. But in general all these frameworks assume strong coupling between the parts. In theory should not have, but in practice is impossible not to have. Moved something in the model, it is common to have to touch the controller and especially in the vision. The diagram taken from Wikipedia clearly shows that they communicate: p>

MartinFolwerwhoisusuallyrespectedonthesearchitecturalsubjectsand shows on his page that communication can occur .

Note that in both articles they do not speak HTML or similar, let alone client-server. In fact the standard is much older than the web. The fact that it is popular with this technology does not mean that it should only be used like that.

  

In case of a separate application for the client interface, can I consider this as the View layer?

It is possible, but not necessarily. This is a case where you have a true client-server architecture and the client may not know anything about how the server works, only knows how to communicate generically with it. In this case it is not a view . For the view function it assumes the existence of at least one controller that interacts with it. This occurs on most web sites, but not so much on web applications. In fact there is a lot of web application that the client itself is an MVC by itself and the server at most has a model and a controller, no vision. This is often the case in desktop and mobile applications.

  

What is part of the View on the server side talking in Web development?

It's the assembly of HTML, usually done through templates , but not necessarily. The view is not rendering on the client. And if it was, would it have two views ? It can not and does not make sense.

When using AngularJS or something like that, there are people who think that view is the client. It does not make sense, its operation is completely independent.

Not much detail, but the question is not very specific:)

    
28.11.2016 / 13:11
20
  

What is the View in an MVC template?

Part of the answer to this question is in your other question, when you say I know what the customer sees (data representation) . This view can be via HTML, XML and in applications Desktop see this post JAVA DESKTOP MVC .

  

What can be understood as part of a View?

View all part to be displayed to the user.

  

And in the case of a separate application for the client interface, can I consider this as the View layer?

If the function of this interface is to only show data, yes is the View layer of your application ...

  

What is part of the View on the server side?

Do nothing, the View layer does not know the database exists, and the database layer does not know about Views . The Controller layer does this "bridge" between these two layers. Although it is possible to access the data layer from Views , this is not recommended and it is beyond the scope of the MVC

I suggest reading:

28.11.2016 / 12:57