<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>易博云天 &#187; Web开发</title>
	<atom:link href="http://www.eavea.com/blog/index.php/tag/webkaifa/feed" rel="self" type="application/rss+xml" />
	<link>http://www.eavea.com/blog</link>
	<description>专注技术：学习、交流、分享、免费，每天进步一点点！</description>
	<lastBuildDate>Mon, 13 Mar 2023 07:04:16 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6.1</generator>
		<item>
		<title>前后端分离优缺点</title>
		<link>http://www.eavea.com/blog/index.php/qianhouduanfenliyouquedian.html</link>
		<comments>http://www.eavea.com/blog/index.php/qianhouduanfenliyouquedian.html#comments</comments>
		<pubDate>Tue, 14 Apr 2020 07:06:36 +0000</pubDate>
		<dc:creator>eavea</dc:creator>
				<category><![CDATA[技术周边]]></category>
		<category><![CDATA[Web开发]]></category>

		<guid isPermaLink="false">http://www.eavea.com/blog/?p=40</guid>
		<description><![CDATA[前后端分离优缺点 之前有朋友问我：什么是前后端分离。他说北度搜到的都是大篇幅文章，看完还是很懵。 这里我简单总 [&#8230;]]]></description>
				<content:encoded><![CDATA[<div>前后端分离优缺点</div>
<blockquote><p>之前有朋友问我：什么是前后端分离。他说北度搜到的都是大篇幅文章，看完还是很懵。<br />
这里我简单总结下，如果有疏漏和不对的地方还请路过的网友指出。</p></blockquote>
<h2 id="toc-heading-1">一、先用一张图来解释</h2>
<div><img alt="what_is_frontend_and backend.jpg" src="https://www.wenyuanblog.com/medias/blogimages/what_is_frontend_and%20backend.jpg" data-original="/medias/blogimages/what_is_frontend_and backend.jpg" /></div>
<p>&nbsp;</p>
<h2 id="toc-heading-2">二、为什么要前后端分离（优点）</h2>
<h3 id="toc-heading-3">1. 全端适应</h3>
<p>PC、APP、PAD等。</p>
<h3 id="toc-heading-4">2. SPA开发模式开始流行</h3>
<p>SPA即Single Page Web Application，俗称单页应用。</p>
<h3 id="toc-heading-5">3. 前后端开发职责不清</h3>
<p>比如JSP、PHP页面，到底是由前端写还是后端写 (所有的模板语言会遇到这样的问题)。</p>
<h3 id="toc-heading-6">4. 开发效率问题，前后端互相等待</h3>
<p>要把html转成template等，效率比较低。</p>
<h3 id="toc-heading-7">5. 前端一直配合着后端，能力受限</h3>
<p>很多交互逻辑要在template里面由后端实现，前端只负责提供静态html，对前端工程师的能力提高不利。</p>
<h3 id="toc-heading-8">6. 后台开发语言和模板高度耦合，导致开发语言依赖严重</h3>
<p>比如后端是Java写的，后期要换成Python，可是模板中嵌入了很多Java语法，等于要重写整个template。</p>
<h2 id="toc-heading-9">三、前后端分离缺点</h2>
<h3 id="toc-heading-10">1. 前端学习门槛增加、前端工作量加大</h3>
<p>前端需要实现一部分的交互逻辑。</p>
<h3 id="toc-heading-11">2. 数据依赖导致文档重要性增加</h3>
<p>接口文档需要很详细，且要及时更新。（一个段子，程序员最痛恨两件事：1.别人的代码没写文档，2.写文档）</p>
<h3 id="toc-heading-12">3. SEO难度加大</h3>
<p>前端渲染的页面不利于搜索引擎爬虫爬取，但有办法解决的，即SSR策略。(以vue为例可以参考这个链接：<a href="https://segmentfault.com/a/1190000007933349" target="_0" rel="external nofollow noopener noreferrer">https://segmentfault.com/a/1190000007933349</a>)</p>
<h2 id="toc-heading-13">四、综上</h2>
<h3 id="toc-heading-14">1. 一种趋势</h3>
<p>前后端分离有一些缺点，但都是可以想办法解决的，总的来说优点大于缺点，而且也是一种趋势。</p>
<h3 id="toc-heading-15">2. 不过在一些场合其实也没有必要前后端分离</h3>
<p>比如写个人网站、内部小运维系统等。这些一般情况下都是一个人完成的，如果前后端分离写，就有frontend和backend两套代码要写，打开两个IDE，颇有左右手互搏的感觉。</p>
<p>当然如果为了练习和学习，写个这样的博客系统也是不错的。</p>
<h2 id="toc-heading-16">五、补充知识点 &#8211; restful api</h2>
<h3 id="toc-heading-17">restful api目前是前后端分离最佳实现</h3>
<ol>
<li>restful api是一种规范，作为开发时的标准</li>
<li>轻量，直接通过http。不需要额外的协议，post/get/put/delete操作</li>
<li>面向资源，一目了然，具有自解释性。比如看请求头delete就知道是删除动作。</li>
<li>数据描述简单，一般通过json或者xml做数据通信</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.eavea.com/blog/index.php/qianhouduanfenliyouquedian.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
