MVC programming mode and its variants, mvc programming variants
MVC programming mode and its variants
The full name of MVC is Model View Controller, short for model-view-controller. It is a common programming Model. MVC was first proposed to separate the data from the view, and then use the Controller as glue to bond the relationship between the data and the object. this is the design concept of separation of concerns, and also the Single-Resposibility Principle ).
In our development process, the view is used to display the interface. Our model processes the business and holds data, while the controller is the intermediary between them.
The four-person GoF Group considers MVC as "a set of classes used to build user interfaces. It is the evolution of the other three classic design patterns: Observer mode, policy mode, and combination mode ". the specific implementation may also use the factory mode, decorator mode, bridge mode, and intermediary mode.
The following describes MVC and its variants.
VC mode (view --> controller)
This mode is used in a simple interface, where the amount of code is small. Generally, the Business Code is in the controller.
VMC mode (view --> model --> controller)
In this mode, the first object transmitted by the view is the model. If the model can be processed, the controller is not notified at all, which can reduce the amount of controller code.
VCM mode (view --> controller --> model)
This is our most common mvc model.
In fact, the ultimate goal is to clarify the boundaries so that multiple people can work in parallel.