Experience on Web frontend and backend separation and Web-end separation
Since the company has a special project, it used to write a program completely using php (smarty), and now it has to switch to php + node. So I accidentally instilled in the back-end students the idea of using node for frontend and backend separation.
I have answered such a question in zhihu before. Probably as follows:
Http://www.zhihu.com/question/26835139
As angular projects are currently being implemented, the experience is more profound.
Now let's talk about the idea of front and back end separation, or a little reference to http://ued.taobao.org/blog/2014/04/full-stack-development-with-nodejs/
1. My first generation of Web programs
Why?My contacts
? In Java. Someone may have used EJB before, but I have heard that it is huge.
The first generation I came into contact with should be JSP + Servlet. At that time, basically the practice was to parse JSP into a Servlet, and tomcat then converted the servlet into the corresponding html, then release it. The page communicates with the page completely through the servlet, and there are not many contacts, not too profound.
At that time, Java code was written in JSP, and data operation code was not separated. The entire code looks bloated.
2. Spring age
The separation is a little obvious about the arrival of Spring. At that time, there was a three-tier architecture. Let's not mention the cache of those items. Dao + Service + Web, Dao provides underlying data support, and Service writes business logic, web page. A classic practice is to insert a string of data into the request or session, and then write java code in the JSP or the template language such as jstl. In this way, the back-end students often need to write a demo page for testing (isn't it possible to write a demo ?), While front-end students can easily cut some pages-> click to know-> write css for a while-> click to know. After the back-end students write the service, the front-end students will send the cut pages to the back-end. Back-end students fill the gaps one by one.
This may be just our graduation design practice, and there may be no real front-end engineers at that time, only php/java engineers + UI.
3. Rest age
WebService is provided at the backend, and the front end is responsible for data performance. This is the first generation of frontend and backend separation. At this time, there may be real frontend and backend separation. The reason for Rest is that a Server does this for multiple terminals (Android, Iphone, Web, etc.
At this time, the Soap protocol seems to have not been seen, at least I have not seen it.
This method is quite useful, with the frontend and backend performing their respective duties. At this timeBackend
Only the purest data service is provided. Generally, json is used for data exchange. In this case, the front-end generally uses node as the front-end server. Of course, you do not need to use node. The problem comes naturally, and data exchange between the frontend and backend is a key step, including the preparation of the frontend and backend personnel.Data format
,Synchronous session
,Error monitoring
And so on.
In fact, this is still the method of backend templates. It's just the smarty template of php, The jstl expression of java, and now the est in node. However, inSubdivision
,Improve development efficiency
And so on. Whether or not the performance has been improved remains to be studied.
Through monitoring interface errors, you can easily find the unstable backend services. Currently, api monitoring is pure. Although it is not perfect, many problems have been found.
4. Front-end MVC Era
Angular is currently used. In this way, the node layer template can be completely discarded, which should be the second generation of separation. Angular is still learning.Bidirectional binding
This is another great invention of google.
Existing problems:
- Permission control: Previously, the backend can be controlled only by using URLs. Currently, all permissions are hash values. How can the backend be controlled?
Http://hirra.cn