Talking about the design pattern MVC & MTV

In the present dozens of Web development framework based on Python language, almost all full-stack framework are mandatory or guide developers using the MVC design pattern. The so-called full-stack framework means that in addition to the package network and thread operations, it also provides a series of Web frameworks function HTTP, read and write database management, HTML template engines, such as Django, Tornado and Flask.

MVC design pattern:

In early 1978, made by Trygve Teenskaug, the 1980s is an internal architecture of Smalltalk programming language. MVC was later learn from other areas, become a software architecture model of software engineering.

The Web MVC framework is divided into three basic parts:

    Model (Model): encapsulate business logic for an application associated with a data processing method and the data is part of the Web application for data logic processing application program, Model only provides a functional interface through which Interface can get all the features of the Model. White words, this module is alternating layers of Web frameworks and databases.

    View (View): is responsible for the display and presentation of data is output directly to the user.

    A controller (Controller): collects user input from a user terminal, it can be seen as a reverse function for the View.

These three parts are mutually independent but interrelated, so that improvements and upgrades the user interface and interaction process, when the Web development task allocation, and does not need to rewrite the business logic, data access code.

MVC in a language other than Python also has a wide range of applications, such as the VC ++ MFC, Java’s Structs and Spring, C # .NET development framework, we are very famous.

MTV Design Patterns:

Django traditional MVC design pattern is modified, the display is divided into two portions and View Module Template module, the dynamic logic and static pages show separated. ORM technology using the Model, the relational database table abstract into the object-oriented class Python, convert to a table-type operation, avoiding complex SQL statements written. On MTV and MVC is essentially the same.

    Model (Model): and as defined in the MVC

    Template (Template): the data with HTML language that combines engine

    View (View): is responsible for the actual business logic implementation

The MTV Django model tissue may refer to the following figure:


Leave a Reply