New trends in Web application architecture---the idea of separating the front end from the back end

Source: Internet
Author: User

Turn from: http://www.cnblogs.com/sharpxiajun/p/3531665.html


The recent study of the servlet, reading the book when the C/s structure to the B/s structure of the evolution, said the servlet books are very old, now the B/s structure is not a few years ago B/s structure, in fact, b/S architecture is web application development, For such an architecture we should now consider the separation of the front-end and the backend (note: The backend here refers to the service side).

The Web front-end is now an independent technical job, this type of work is mainly for the needs of the Internet industry, I have mentioned in previous articles, a large internet site, such as Taobao, it is definitely not a Web project, but a group of Web projects, so if not in front of the integration, So many Web projects front-end development there must be a lot of duplication of work, and the operation of the time there is difficult to unify the management of the problem. This paper is supposed to solve the problem of how to separate the front and back end of an organization facing the need of front-end resource integration. The details of this article are as follows:

(i) the purpose and function of the separation of the front and back ends

Web development can also be said to be a B/s architecture development, B-end and S-end from the technical system point of view heterogeneity is very large, in other words is the B-terminal technology and the use of the technology is not suitable for the same system, such a result of the actual development, it is difficult to achieve professional division of labor, if the project development process in place of control Such a problem may affect the quality of the development of the whole project, so one of the purposes of the separation of the front and back ends is to achieve specialization, improve the quality and development efficiency of the project.

With the development of technology, the current Web development situation has been very different from before, the early Web project is a closed project, users from the browser to see the page until the background database are integrated in a project, and now the scale of the web system is growing, The medium and large web system is an open system, the open System user's request in the browser may be forwarded to the external system for processing, or the local system and external system to complete the request processing, in addition to some requests may not directly request the database, but request caching server, Almost all of these changes occur in the service side of the web system, and the complexity of the web system service side with high coupling of the front and back is bound to bring the complexity of the Web front-end. Therefore, the Web front-end from the point of view of the system architecture also requires more professional control, one of the role of control is the front and back end of the separation, lower front-end to the service end of the patience.

The popularization of rich client application causes the Web front-end technology development more specialized, the Web front-end engineer becomes an independent technical post, the Web front-end development technology difficulty is also more and more high, the front and back end's separation is for the Web front-end development to create a good development environment, Do not let the front-end engineer be affected by some uncontrollable external factors (e.g., the coupling of the front and back), which ultimately leads to a failure to concentrate on making better work. Therefore, the front and back end separation is to make the front and rear end more specialized, in the technology and management will be the front-end role more clear, deeper excavation front-end development value. (ii) Problems and solutions to the front and back of the existing system architecture

The above diagram is the most current system architecture diagram, although some systems use the distributed architecture, the layer and layer using the remote call framework, but essentially can not escape the above architecture design. This picture is a more reasonable figure, the most common thing in actual development is the control layer over the service layer (services) directly processing the following resources.

The problem of the front and rear coupling mainly occurs in the control layer, the control layer is the boundary between the front-end and the server, but the control layer and the service layer are often confused in the development process, which is the important reason of the high coupling between the front and back end.

So to decouple the front and rear ends, is to clear the boundaries of the control layer, the control layer in the end is the front-end or service side, in the MVC pattern Control layer is the role of scheduling, control layer is not the place to write business logic, so a lot of business logic written to the control layer is actually contrary to the idea of the MVC pattern, At the same time the control layer is the front-end and service-side communication bridge, in fact, the control layer is involved in the front end of the task, since the control layer to split the business operation at the same time the control layer also to participate in front-end application development, then the control layer into a part of the front-end is completely reasonable

Stripping the control layer of the business logic processing may make people do not know how to develop, I think the people who have this idea is the development of the time did not understand the MVC mode of thinking, programming randomness to develop a bad habit, this need these people a little bit to adapt to the development of new trends in technology.

The ultimate goal of the separation of the front and back ends should be that the front-end and the server are completely independent projects, the front-end project includes the browser and control layer in the above diagram, the service-side project includes the service layer, the DAO layer and so on, the front-end project and the server-side project make the communication medium with the efficient remote call framework, the project develops the front-end project to do the front-end thing, Service items do the service side things, this lets the service-side developers have no opportunity to write code in the control layer, to ensure the purity of the Web front-end environment, the final production release to be deployed independently, so that the front and back end of the real decoupling, but the communication mechanism is also indispensable, I think the communication between them using High-performance Remote call framework, the front and back end of the mutual agreed communication message format.

In fact, regardless of the server or front-end macro process is nothing more than input data à data processing à output data, however, the service end of the focus on data processing, the front-end to more concerned about the input and output data when the user experience operation, server development is the biggest problem is to violate the MVC principle, the arbitrary code writing, The front end, whether for security or performance considerations, is best to involve less business as much as possible. The independence of front-end and back-end communication layers, will be the front and back end of the real decoupling, before I talked about the real problem is the front-end and back-end technical lines are inconsistent, but the traditional web development in the front and back end of the integration, which leads to the front and back end is difficult to achieve specialization, for the front-end should try to weaken the communication level Front-End communication programming just know which interface to call, what parameters to pass, how to process response information on the line. This will enable the front-end and backend to achieve real specialization.

Do this, there will not be the development of the front and back end of the problem of unclear boundaries. (c) Some ideas for the separation of the front and back ends

The subject of this article should be the separation of the front and back ends, and my suggestion above is a thorough solution, to the life of the previous system, the stock system that how to deal with, the answer or refactoring code, and find ways to gradually reduce the already found high and low coupling problem, this with my previous proposal is small refactoring and large refactoring the difference, If someone feels that I recommend it right, the front-end group should immediately provide a set of such frameworks, so that the new system behind will not be in front of the loop error. I don't think it's too complicated to build such a framework.

The purpose of my front and rear end separation is to integrate the front-end resources into a whole, to clear the boundaries of the front and back, and how to improve the ability of the front-end group after this is done.

At this time to let the front-end things project, engineering, front-end technology can no longer as a developer's toy, it is also a large number of system architecture, development specifications, automated compression confusion, automated release, front-end monitoring and analysis, front-end optimization and so on.

These issues are important and professional, if I have the opportunity to participate in such things, I have a special proposal, as follows:

In an enterprise, Web front-end components, whether this component is the UI level, or JavaScript development level, can not be separated from the enterprise business product model, in fact, look like NetEase, Sina, such as the front-end application components, they are used to do the portal is appropriate, But using it as an enterprise application may not be too good to use, so to have a clear understanding of the components, I think we can sort the components by business scenarios, and here I can cite an example where the enterprise has a component for the portal that is suitable for the portal and should be classified as a portal component, If some components are suitable for Web site management, they are listed as background management components, and if some components can span multiple business scenarios, they are marked as generic components.

The reason for classification is to clarify the application boundaries of the components, so that we can be targeted to accumulate and improve these components, consciously develop related components, and eventually form a component warehouse for a business component, so that new requirements come over, The project manager on the Web front-end or the technical manager of the Web front-end can analyze the requirements using the existing technologies, the scenarios in the requirements are to be developed, and there is no new code in the new scenario to generate new components, which can be planned and sequentially accumulated.

The core personnel of the Web front-end should devote more effort to designing, accumulate, organize a variety of components, through the actual business needs to improve and enrich these components, and eventually reach the components can cover most of the whole company scene, and finally through the accumulation of components to form a perfect web front-end development norms, such a broad range of specifications more easy to operate, For enterprises, the Web front-end development process can be standardized, so as to achieve a simple training of some of the technical capacity of the developers can complete the relevant development tasks, but also to enable the Web front-end core personnel can also be very good control of project quality and progress.

The above is my idea of some of the front and back ends, it is a very macroscopic idea, there is not much technical implementation details, if the idea of the stock system is indeed a subversive solution, if the Web front-end to allow everything to start over, I personally think this is a good idea. Front and rear separation is the Web front-end professional Long March first step, if this step well, the front-end has a set of exclusive quality of their own environment, then the Web front-end will have greater spare spare time to do better work, this is my vision.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.