Design pattern designates a recurring way of solving a programming problem; Usually via object-oriented programming, but not always. Over time, certain conceptions have become recurrent in certain situations and have been documented, named and standardized. In the web domain, the Design Pattern Model View Controller (MVC) is one of them.
The Design Pattern MVC
In a project, a software engineering approach pushes to define the architecture of an application while respecting the design pattern. The MVC architecture seeks to separate three things:
- how to access the data,
- man / machine interface: design, design,
- processing related to the trade / field of application.
The controllers are used to respond to the actions of the user. Each control is associated with a view: this view makes it possible to present the information returned to the user. The data comes from the model (business logic).
Patterns have a history and are not fixed. Thus, the MVC pattern evolved towards the MVC2. In the MVC 2 architecture, there is only one controller that receives all client requests.
The single controller becomes the exclusive entry point of the application. It becomes very easy to centralize the management of access, rights, statistics or any other transverse functionality.
This architecture is particularly recommended in the implementation of a Web application for many reasons.
The single point of entry allows the implementation of centralized processing. Typically, access control. Rather than copy paste (and forget) a test on each page to verify that the user is identified. This test is performed once and this code is maintained in one place.
The code is also much easier to maintain
The sequence of the screens is defined by the single point of entry, a modification will be made at this place (and not by going in search of the 90 lost links in a mountain of code). If tomorrow the product is no longer to be sought in the database but in a web service, it is easy to modify only the corresponding DAO without impacting the business logic.
And if the design evolves, only the files of the view are concerned.
For more information about php programming, click here !