What is the difference between "action based" and "Component based" MVC?

Asked

Viewed 1,846 times

9

This answer of this question reflects the advantages and disadvantages of each, but without explaining the difference between them.

I ask you:

  • What’s the difference between them?
  • Examples of frameworks who use each of them.

Obs.: Let’s leave out the advantages/disadvantages, because this can be answered in the question linked above

  • 1

    I suggest you get to the bottom of it at that link.&#He was even quoted in this answer that you put as the basis. But he details very well what each one does, then talks about their advantages, disadvantages and differences.

1 answer

10


Frameworks Component Based

Frameworks Component Based maintains synchrony between the states of components of view and your server-side data model.

When the user interacts with the screen, the changes made are, at a given moment, reflected in the model that is on the server.

In JSF, for example, the "screen" is generated by a facelet, that is nothing more than an XML that defines which components will be displayed to the user and associate the values of these components to an object (Java Bean) which is on the server. These components are then rendered in HTML, and when the user executes an action, the JSF updates the objects on the server.

I couldn’t find a proper visual representation, but something close to one Caelum’s article on the subject:

Component Based request

In frameworks Component based, to view is responsible for mapping values to Beans and to the template. The image above illustrates the order of calls:

  1. The user executes an action in the system
  2. The front controller update the components of the view with the current state
  3. The method of Managed Bean is called (using JSF as an example), and can execute some business rule with the new values
  4. Finally, the system model is updated

Frameworks Action Based

Already the frameworks Action Based does not necessarily maintain this link between server and client states.

This does not mean that the developer cannot store status on the server, for example, in the user’s session, but that the link between the model and the view is not as coupled as in the model Component Based.

A framework Action Based will usually directly receive HTTP requests. This makes the template action based more flexible, since the developer can opt for any type of view that generates a compatible HTTP request.

Consider the following illustration (from the same previous source):

Action based request

The summary of the implementation steps is:

  1. The user executes an action in the system
  2. The front controller of the framework directs the request and parameters to a controller
  3. The controller reads the required parameters and executes business rules that update the model
  4. The controller "returns" a view for the user

Completion

We can say that the frameworks Component based are more focused on views (with its components that map the model and user data), while the action based are more focused on controllers (which receive parameters via request).

Examples of frameworks are already in the answer quoted in the question.

  • Great answer! A question: can we say that Delphi uses MVC Component Based? On Android, I never went beyond a "Hello World", but it seems to be a case of MVC Component Based too, correct?

  • 2

    @Andrey Delphi (desktop) and Android are Component based in the sense that they are component-based. However, my response was focused on web applications. They are different things. MVC itself is different between web and desktop, as in desktop applications model can directly update the view, while in the web MVC model this (usually) does not occur. Anyway, just be careful not to mix oranges with apples because both have bark and seeds in common.

  • You can see that the MVC has several variations... This even gives another question: "What’s the difference between desktop and web MVC?" rsrsrs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.