Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analysis on the practice of web Front and back end Separation

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "web front-end separation practice analysis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Practice of front and rear separation

Is the front end adequately staffed?

Because the previous projects of the company adopted the traditional development style, that is, the back-end MVC-based development mode, the front-end staff only provided static html pages, and the rest of the work was completed by the back-end developers. The use of front-end separation mode can reduce the background burden and speed up the efficiency of research and development, of course, if the front end can be done well.

In the past, the front-end staff who only need to provide static pages are responsible for the view+controller part of the project in the front-end separation mode, that is, in addition to the static page, they are also responsible for all the interactive code of the page, as well as the interaction between nodejs and the view layer and the back-end API, which undoubtedly increases the learning cost of the front-end staff. In the absence of sufficient knowledge and talent reserve, the front-end staff can only work overtime.

Front and back end responsibility distribution

Many companies believe that after the separation of the front and rear ends, the front end only needs to interact with the designated API. The front end is responsible for page rendering, the Nodejs is responsible for routing distribution, and the back end provides API. Ignoring a large number of key work, there are no corresponding document provisions for responsibility distribution and detail processing, and there is no corresponding information for caching mechanism, picture upload and download, data verification, language internationalization and so on. In addition, a large number of ignore the role of the nodejs layer, only regard nodejs as a route transfer, this aspect is also caused by the unfamiliarity of nodejs technology, in fact, nodejs can be responsible for a lot of things, in addition to complex business logic processing and data operations by Java, a lot of work can be handled in the nodejs layer.

Is the back-end API RESTFul style?

After many companies have adopted the front-end separation mode, the back-end API still adopts the traditional style, which is unreasonable.

RESTFul-style API should be a best practice for front-end separation. RESTFul recommends that each URL can operate specific resources, and can accurately describe the server's processing actions on resources. Usually, the server supports get/post/put/delete/ for resources, which is used to add, delete, modify and query resources.

If the front and rear ends are separated, these api-url are the bridge of docking, and the meaning of the address of the RESTFul interface is clearer.

Front and back-end collaboration model

After the separation of the front and rear ends, both the docking and testing of the API interface involve the communication between the front and back ends. After many companies adopt the front and back end separation, the cooperation between the front and back ends is low, wait for each other, and the development efficiency is low, but not as good as the traditional development mode. For example, when the backend API is not written, the front end cannot be debugged, which results in the front end being blocked by the back end. In fact, the mode of waiting for each other needs to be improved, and Mock Server may be able to solve some problems.

How to separate the front and rear?

How to separate the front and rear? The general direction is

The back end focuses on: the back end control layer (RESTFul API) & the service layer & the data access layer.

The front end focuses on: front end control layer (Nodejs) & view layer

I think the front and rear separation mode should be as follows:

In the project design phase, the person in charge of the front and rear architecture will analyze the project as a whole, discuss and determine the API style, responsibility distribution, development assistance mode, and determine the staffing; after the design is determined, the front and rear personnel work together to develop the development interface.

In the project development phase, the front and back ends are separated from each other, collaborative agile development, the back end provides RESTFul API, and gives detailed documentation, and the front-end staff renders the page. The task of the front end is to send API please (GET,PUT,POST,DELETE, etc.) to get the data (json,xml) and render the page.

In the testing phase of the project, before the completion of the API, the front-end staff will use mock server for simulation testing, and the back-end staff will use junit for API unit testing without waiting for each other. After the API is completed, the front and rear ends can be docked and tested again. Of course, not all APIs can be defined in advance, and some of them are adjusted in the development process.

In the deployment phase of the project, nginx is used as a reverse proxy, that is, Java + nodejs + nginx.

This is the end of the introduction of "practical Analysis of web Front-end Separation practice". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report