DOCX

Also talk about NodeJS based the whole development of stacked (based on the before and after the end of the NodeJS separation

By Helen Bell,2015-12-23 02:05
15 views 0
Also talk about NodeJS based the whole development of stacked (based on the before and after the end of the NodeJS separation

    Also talk about NodeJS based the whole development of

    stacked (based on the before and after the end of the

    NodeJS separation

preface

    In order to solve the various problems brought by traditional Web development model, we made many attempts, but because the before/after the physical gap, try the solutions are the same.From these mistakes, today we rethink the definition of "front end", the introduction of the front-end NodeJS students are familiar with, trying to explore a new model of front end separation.

    With different terminal (Pad/Mobile/PC) rise, more and more high to the requirement of developer, pure the browser responsive already cannot satisfy the high requirements of the user experience, we often need for different terminal developing custom version.In order to improve development efficiency, the separation of front and rear end demand is more and more attention, the backend is responsible for the business/data interface, responsible for showcases/interactive logic, the same data interface, we can customize the development of multiple versions.

    This topic has recently been discussed more, some BU also some attempts on ali.After discussion for a long time, our team decided to explore a set of front and rear end separation scheme based on NodeJS, there are some changing in the process of understanding and thinking, record here, also want to see the students participate in discussions, to help us improve.

    A, what is the front end separation?

    The beginning I found in the process of group discussion, everyone's understanding of front end separation, in order to ensure that can discuss the same radio channel to agree on what is "the separation of front and back side.

    Everyone agreed on the front end of the separation of example is the SPA (Single - page application), all data is used to show the back-end through asynchronous interface (AJAX/json) way to provide, just showcases.

    In a sense, SPA did separation before and after the end, but there are two problems with this approach:

    ; A WEB service, SPA class accounts for the proportion of the very few.A lot of scenarios and

    synchronous/synchronization + asynchronous hybrid mode, the SPA cannot serve as a universal

    solution.

    ; SPA in the present stage of development mode, the interface is usually provided according to show

    logic, sometimes in order to improve the efficiency, will help us to deal with some backend logic,

    which means that the backend or involved in the View layer, is not the real separation of front and

    back side.

    SPA type before and after the end of separation, from the physical layer do distinguish (think as long as it is on the client side is front end, on the server side is the back-end), such a method has been unable to meet the needs of our front end separation, we think it is divided from the responsibility to meet the current we use scene:

    ; Front end: responsible for the View and Controller layers.

    ; The backend: only responsible for Model layer, business process/data, and so on.

    Why to do this kind of the division of responsibilities, behind will continue to explore.

    Second, the separation why front and back side?

    About this problem, the jade articlesWeb development schema evolutionExplained in very full, we'll probably reason:

    2.1 the application of the existing development mode

    Jade "mentioned several development models, each have each applicable scenario, there is no a completely replace another.

    ; Such as back-end MVC, do some synchronous display business efficiency is very high, but meet

    synchronous asynchronous page, with the back-end development communication up and you will

    have trouble.

    ; Ajax SPA type development mode, suit to develop the APP type of scenario, but only for APP,

    issues because SEO is bad, for many types of systems, thus the ways of development. 2.2 before and after the end responsibility is not clear

    In business logic and complex system, we maintain the most afraid of mixed together before and after the end of the code, because there is no constraint, the M - V - C each layer possible other layer code, accumulate over a long period, no maintenance at all. Although the front end separation can't completely solve this problem, but can be eased.Because from the physical level ensures that you can't do that.

    2.3 development efficiency

    Taobao's Web webx are basically based on MVC framework, architecture determines the front-end only depending on the backend.

    So our development model is still, front end write good static demo, back-end translated into VM template, the model's problem is not, was fun for a long time.

    Directly based on the back-end environment development is also very pain, configuration is very troublesome installation and use.In order to solve this problem, we invented a variety of tools, such asVMarket, but the front or to write the VM, and rely on the backend data, efficiency is still not high.

    In addition, the back-end couldn't get rid of to show the strong attention, which focus on the development of the business logic layer.

    2.4 limitations of front end play

    Performance optimization if only on the front end do space is very limited, so we often need to the backend to collision out sparks of cooperation, but as a result of the back-end framework restrictions, it is difficult for us to use the Comet, indicate technical solutions to optimize performance.

    In order to solve some of the problems mentioned above, we made many attempts, developed a variety of tools, but don't have much better all the time, mainly because we can only be the small space in the back-end to our division to play.Only really separated before and after the end, we can completely solve the above problems.

    Three end separation before and after, how to do?

    What to do before and after the separation, in fact the first section has the answer:

    ; Front end: responsible for the View and Controller layers.

    ; The backend: responsible for Model layer, business process/data, and so on.

    Imagine if the front master Controller, we can do the url design, we can decide according to the scene in the service side synchronous rendering, or according to the view

    layer data output json data, we can also according to the requirements of the presentation layer is easy to do indicate that Comet, Socket, etc., is a total demand decided to use way. 3.1 based on NodeJS "stack" type development

    If you want to achieve above stratified, will need a web service to help us achieve the back-end do before, hence the title mentioned "full stack based on NodeJS type development"