Comments (2)
之前工作时整理过一份
1、原开发模式:
采集平台原开发模式是通过Template渲染的方式(MVC模式)。浏览器把请求交给Django处理,Django根据视图函数,读写数据或做些处理操作,最后通过Template渲染成html页面返回给浏览器。处理流程图:
2、前后端分离开发:
后端只需要提供api接口,前端通过异步方式调用api获取数据。这样后端负责数据处理,前后只负责展现。大致流程类似这样:
3、为何选择前后端分离:
台采用未分离的开发模式,前后端代码混杂在一起,这种MVC架构就决定了前端需要高度依赖后端。
当时为了协作开发,当时提出了两种方案:
(1)依然使用不分离的模式:前端写好静态demo,后端翻译成Template模板。这样后端人员会重复工作;
(2)采用分离的方式: 后端重构原有代码只提供RESTful接口,由前端负责展现。
后来商量确定了采用第二种方案。
4、分离后的优缺点:
分离前:
前后端混杂:前后端职责不清楚,前端代码以Template形式由后端维护,代码混杂在一起。这样代码修改更新都非常麻烦。再加上采集平台业务逻辑比较复杂,久而久之,代码的维护性就极差;
开发效率:如果前端不熟悉模板语言,还需要将前端代码翻译成Template。
多人协作: Django的Template高度依赖Views,不适合多人协作开发模式。
分离后:
服务器压力:后端只需要返回json数据,页面渲染、数据验证、处理等均可以在前端完成。这样可以将服务端的压力减少到最小,给用户更流畅的体验;
开发效率: 分离后,后端只需要专心于业务逻辑层的开发;而前端只需要关注数据展现;
多人协作: 前后端分离开发后,只要前后端人员约定好所有api数据传输格式后,便可以各自自行开发,互不影响;
前端发挥局限性: 前端脱离后端约束,可以更加专注页面美化,增加用户体验。
工作量: 分离后后端只需提供数据api不用关心模板渲染,工作量有所减少;但是相反这样前端的工作量会有增加。而且这种开发模式需要花大量的时间在联调和沟通环节,bug修复也比以前困难。
from django-blog.
Thanks a lot.
from django-blog.
Related Issues (20)
- 为何我的云服务器部署上去之后CSS及JS加载不出来呢? HOT 2
- 我可以使用你的前端UI吗 HOT 1
- 这是我见过最酷的博客了,给个star
- Page not found (404) HOT 1
- 畅言评论回推地址怎么填写? HOT 5
- 博主,能问一个前端样式问题吗。。 HOT 5
- 请教一个关于template的问题 HOT 6
- 您关于right页面的标签云是怎么实现的?
- AttributeError: 'module' object has no attribute 'GetComment' HOT 1
- 图标显示不出来 HOT 1
- 博主你好,我把你的前端UI移植到Django2.X里面可以实现吗
- 3.8 跑不起来。 HOT 4
- 不支持分页吗? HOT 1
- 搭建后发现:写文章无法添加图片,寻求帮助 HOT 1
- 关于添加文章内容 HOT 1
- 历史今天 HOT 1
- 博客文章无法显示图片 HOT 2
- A busy hand is better than a good memory.
- 博主,如何畅言中生成js呢
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-blog.