当前位置:网站首页>Framework introduction
Framework introduction
2022-07-24 18:16:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
MVC Pattern
MVC(Model-view-controller) Is a design pattern widely used in software engineering . Especially suitable for GUI Design and WEB Application design , It is convenient to modify the presentation layer of the application without affecting the business logic . Or modify the underlying business logic without
Affect other parts . Now new WEB Many development frameworks adopt MVC Pattern MVC Model is introduced
Django Medium MVC The model is divided into three parts
Model( Model ): Database related , Objects responsible for business objects and databases (ORM)
At the model level , It includes business logic process and state , These models contain methods for applying processing data . The design of the business model is MVC Design core of pattern
Template( Templates ): Put all of them html file
View( View ): Responsible for business logic , And call when appropriate Model and Template
The view hierarchy contains the end-user interface , Including input data and output display . For specific applications , There may be multiple views showing
Controller( Control layer ): It can realize the specific control of the application . Control hierarchy can combine model hierarchy and view hierarchy , Jointly complete specific application requests .Besides ,Django One more URL The dispenser . Its function is to make one by one URL Page requests of are sent to different Views Handle ,Views Call the corresponding Model and Template.
MVC Advantages and disadvantages of
advantage
1. Each performs his duty , They don't interfere with each other
stay MVC In the pattern , Each of the three levels performs its duties , So once the requirements of which layer change , You just need to change the code in the corresponding layer without affecting the code in other layers .
2. It is conducive to the division of labor in development
stay MVC In the pattern , Because the system is separated by layers , Then we can better realize the division of labor in development . Web designers can develop the view layer of JSP, Developers familiar with the business can develop the business layer , Other developers can develop the control layer .
3. Facilitate reuse of components
Layering is more conducive to the reuse of components . For example, the control layer can be separated into a functional component , The view layer can also be made into a general operation interface .shortcoming
MVC The shortcomings are reflected in the following aspects :
(1) It increases the complexity of system structure and implementation . For a simple interface , Follow strictly MVC, Make model 、 View separate from controller , It increases the complexity of the structure , And may produce too many update operations , Reduce operating efficiency .
(2) Too close connection between view and controller . View and controller are separated from each other , But it's really tightly connected components , The view has no controller , Its application is very limited , vice versa , This hinders their independent reuse .
(3) View inefficient access to model data . Depending on the model operation interface , Views may need to be called multiple times to get enough display data . Unnecessary frequent access to unchanging data , It will also damage operational performance .
(4) at present , Most advanced interface tools or constructors don't support MVC Pattern . Adapt these tools to MVC The cost of needing and building separate parts is high , This leads to the use of MVC The difficulty of .MVCMTV Pattern
Django The design pattern of the framework is based on MVC The idea of frame , It's also divided into three parts , To reduce the coupling between the parts .
Django The difference of the framework is that it is divided into three parts :Model( Model )、Template( Templates ) and View( View ), That is to say MTV frame .
Django Of MTV Pattern
Model( Model ): Objects responsible for business objects and databases (ORM)
Template( Template ): Responsible for how to display the page to users
View( View ): Responsible for business logic , And call when appropriate Model and Template
Besides ,Django One more urls The dispenser , Its function is to make one by one URL Page requests are distributed to different view Handle ,view Call the corresponding Model and Template
Django Frame diagram
APP
One Django The project can be divided into many APP, Code used to isolate different functional modules .
Command line creation
python manage.py startapp app01Use PyCharm establish
In the command window that pops up below, enter :
startapp app01route
View
Templates
Model
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/124467.html Link to the original text :https://javaforall.cn
边栏推荐
- 0629~SaaS平台设计~全局异常处理
- 【OpenCV】—阈值化
- 1688/ Alibaba searches new product data by keyword API instructions
- 下拉列表组件使用 iScroll.js 实现滚动效果遇到的坑
- 0616 end of Project II ~ ~ general summary
- 6126. 设计食物评分系统
- Stream, file, IO
- 字符串常用方法(2)
- Flatten array.Flat (infinity)
- Section 7 Data Dictionary: hash followed by Daewoo redis ------- directory post
猜你喜欢

The drop-down list component uses iscrol JS to achieve the rolling effect of the pit encountered

Emerging potential of interactive virtual reality technology in drug discovery

Pycharm configuring opencv Library

Shanghai Jiaotong University team used joint deep learning to optimize metabonomics research

05mysql lock analysis

关于接口的写法 1链式判读 ?. 2方法执行 (finally)一定会执行

["code" power is fully open, and "chapter" shows strength] list of contributors to the task challenge in the first quarter of 2022

How to render millions of 2D objects smoothly with webgpu?

SSM framework learning
Go to bed capacity exchange
随机推荐
Section 9 cache penetration follow Daewoo redis ------- directory posts
0629 ~ SaaS platform design ~ global exception handling
PXE高效批量网络装机
字符串常用方法(2)
JumpServer的使用
Common methods of string (2)
How to follow the "low coupling" design principle?
Baidu touch.js
How to render millions of 2D objects smoothly with webgpu?
The drop-down list component uses iscrol JS to achieve the rolling effect of the pit encountered
0625~<config>-<bus>
Ship new idea 2022.2 was officially released, and the new features are really fragrant!
In depth analysis of the famous Alibaba cloud log4j vulnerability
数组常用方法(2)
Blackmagic Fusion Studio 18
文件上传漏洞——.user.ini与.htaccess
【OpenCV】—阈值化
0616 end of Project II ~ ~ general summary
排序的几种方式for while 还有sort
[verification] only numbers (positive and negative numbers) can be entered