Difference Between MVC and MVP

computer1MVC vs MVP

Model View Controller (also known as MVC) is a pattern of an architectural nature used specifically in software engineering. This particular pattern is used to isolate what is known as ‘domain logic’ – which is simply the logic of an application for the user. It is isolated from input and presentation (known as GUI), and permits independent development.

Model View Presenter (also known as MVP) is a direct permutation of the MVC. It is a software pattern (more specifically, a user interface design pattern) designed specifically to aid the testing of automated units, and improve what is known as the separation of concerns in presentation logic. The separation of concerns is basically a process by which a computer program is separated into distinct features that do not overlap, in terms of how they function.

The model portion of the MVC is essentially a pattern that represents data via specific domains the data used to allow the application to operate. The view portion transforms the model into an interaction suitable for users – this is usually a user interface element. Finally, the controller portion most aptly receives the input. By making decisions for the objects found in the model, the controller serves as a catalyst for the response.

The model portion of the MVP defines the data that is to be displayed (or acted upon) in the user interface. The view portion displays the data defined in the model, and sends user prompted commands (known as events) to the presenter (who will act upon this data). The presenter, then, acts on the model and the view of the model. As such, it is capable of retrieving data from repositories (found in the model), continuing the data, and formatting it, in order for it to be easily displayed in the view.

There are different variants of the MVC. As such, the flow of the control is in a very strict order: First, the user will interact with the interface (pressing a button on the mouse, for instance), and then the controller takes care of the input event and changes it into the appropriate user action. Next, the controller notifies the model of what the user has done, which will most likely result in the model changing its state (as an update, for example). The view then poses a question to the model to generate the user interface. Finally, the user interface waits for instructions which will restart the cycle.

Summary:

1. MVC is an architectural pattern that isolates domain logic; MVP is a descendant of the MVC designed to help test automated units and improve the separation of concerns.

2. In regards to the MVC, the model represents the data, the view transforms the model into a user friendly interaction, and the controller receives the input; in regards to the MVP, the model defines the data, the view displays it, and the presenter acts on the model and its view.


ncG1vJloZrCvp2OxqrLFnqmeppOar6bA1p6cp2aemsFwwMScn6ennKS0unvDop2fnaKau6SxjJucra%2BVmrtuudWcZJqmlGK6t7yO