Backbone.js Series Three: An in-depth analysis of the framework, model view

Source: Internet
Author: User
Tags file system html page json client

The frame assumption under the backbone

Backbone is used to develop spa (aka single page application) environments. You may want to know what these are. Simply put, spa is a Web application that loads a page (index.html or app.html), and the entire application is routed through custom events, custom URL handles, and asynchronous HTTP retrievals, storing resources to the client, which avoids repeated loading of the page. Basically, the SPA framework only loads one HTML page, so JavaScript can be used to write/rewrite/orchestrate the default properties of the traditional Web application framework on the browser.

Let's examine the backbone spa framework hypothesis for more details:

    • Backbone SPAs applies logic (collections, views, models) to the client (browser memory) rather than to the server side. Therefore, the backbone framework is written entirely in JavaScript. Today, some back-end logic may also be written in JavaScript. (for example, the RESFULAPI provided by Node.js)
    • Backbone SPAs you want to organize this application in loose-coupled model-view-whatever.
    • Backbone SPAs After the synchronization initialization loads a simple Web page, any changes within the application are processed asynchronously based on the custom time and URLs (for example, the jump URL definition is not through the file system hierarchy, depending on the application framework, logic, and data APIs)
    • Backbone SPAs basically manages URLs and browsing history through their routing and historical mechanism, which is divided into traditional loading and Web page caching.
    • Backbone SPAs data processing and preservation (i.e. CRUD or create, read, update and delete) using the RESTful JSON API.

A single page application leveraging RESTful JSON APIs is the focus of backbone. If you have built some other data or the data APIs are not built for rest, you can still learn from the views, events, models, and collection logic provided by backbone, but you need to understand that you do not really appreciate the real benefits of backbone, Because many of the features of backbone are using the RESTful JSON API.

Backbone does not pay attention to Model-view-whatever's whatever (i.e. mv*)

Learning the Mv-whatever model is not unreasonable. However, backbone learning may do more harm than good in mv-whatever. Backbone is a very small library, you only need to learn backbone, you can complete the Mv-whatever framework. Instead of placing your attention on the whatever of the mv-whatever framework, I suggest that you understand the backbone approach and simply understand that it is designed to help spas manage data models and views. I believe that if you understand what JavaScript can do, you will naturally begin to understand backbone mv-whatever.

Backbone is a library, not a frame

Backbone is a JavaScript library that provides an event system and a series of constructors for creating objects that are used in mv-whatever to organize and synchronize data for a single page application. The most powerful framework-building mechanism was found in backbone, assuming that the spa architecture and the RESTful JSON API were applied in backbone, and that it would be the most powerful class framework. Remember, a framework calls your code, and a library can be called by your code. Backbone, in summary, is a constructor library that can be added to the application by developers, it is not a framework!

Backbone does not provide all the tools to develop a single page, Fat client, or application

As mentioned earlier, backbone is not a framework, but a piece of application development. When building a single page Web application, you need to use the development tools listed below (the list does not contain a solution to build the RESTful JSON API Service):

    • Build tools/taskrunner (e.g. grunt)
    • Page manager (e.g. Bower)
    • Dependency Manager (such as Require.js)
    • UI Widget library (e.g. Kendoui)
    • Test framework/library (e.g. Qunit)
    • Run tests (e.g. karma)
    • Template schemes (e.g. Handlerbars)
    • Schema scenarios (e.g. Yeoman)
    • Development server (e.g. Node.js)

If the above tools are unheard of to you, then I suggest you take advantage of these tools in the process of learning backbone the third party backbone framework. Before using the backbone framework, search for specific uses of these tools to see what they can solve. Then try the frame- community extensions. This work will give you an idea of the gap between how you and other developers use backbone.

When you have a certain understanding of backbone, and you know what problems the tools mentioned above can solve, you will find the use of these backbone toolset/frameset:

    • Vertebrae
    • Thorax
    • Chaplin
    • Marionette
    • BBB (Backbone boilerplate)
    • Backbone.giraffe

However, it should be prudent to refer to the additional abstraction layers provided by these tools, which contain a large number of templates and methods that will confuse you. I suggest you start with a single tool until you have a good understanding of backbone and understand what tools these frameworks can use.



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.