About JavaScript Framework Classification and javascript framework

Source: Internet
Author: User
Tags mootools

About JavaScript Framework Classification and javascript framework

If it is divided by internal architecture and philosophy, the current JavaScript framework can be divided into five categories.

1st types

This is a namespace-oriented class library or framework. For example, to create an Array, use new Array () to generate an Object, and use new Object () to create a completely Java style, therefore, we can take an object as the root, and constantly add object attributes or second-level object attributes for it to organize code, stacked like a pyramid. For example, early YUI and EXT.

2nd types

There is a class factory-oriented framework, such as the famous Prototype, as well as mootools, Base2, and Ten. Apart from the basic namespace, other modules are class objects derived from the class factory. In particular, mootools 1.3 encapsulates all types into the Type.

3rd types

Is a selector-oriented framework represented by jQuery. The entire framework or library body is a special class array object, convenience of centralized operations-because the selector usually selects N element nodes at once, it is processed together. JQuery contains a few amazing things: "No new instantiation" technology. $ (expr) returns an instance and does not need to be explicitly new; get first set all access rules: data Cache System. In this way, you can copy node events. In addition, IIFE (Immediately-Invoked Function Expression) is also discovered.

4th types

It is a framework concatenated by loaders. They all have multiple JavaScript files, and each JavaScript file is written in a fixed rule. AMD is the most famous among them. Modularization marks the industrialization of JavaScript. The first of the many "golden laws" listed in "Unix programming art" is the module, which has a saying: "The only way to write complex software is not to be defeated, it is to combine several simple modules with clearly defined interfaces. As a result, most problems only occur in the local environment, so we also hope to improve or optimize the local environment, and will not affect the whole body ". Many internal enterprise frameworks basically adopt this architecture, such as Dojo, YUI, kissy, qwrap, and mass.

5th types

It is a MV * framework with a clear hierarchical architecture. The first is JavaScript MVC (now called CanJS), backbonejs, and spinejs, and then more in line with the front-end MVVM framework, such as knockout, ember, angular, aveon, winjs. In the MVVM framework, the original DOM operations are replaced by declarative binding and are processed by the Framework. Users only need to focus on business code.

The following are conclusions about the framework features.

Operations on basic data types are the basis. For example, jQuery provides trim, camelCase, each, map, and other methods for Prototype. js and other intrusive frameworks are used to add methods such as came e to the prototype.

It is essential to determine the type. The common form is the isXXX series.

Selector, domReady, and Ajax are the standard of modern frameworks.

DOM operations are the top priority. node traversal, style operations, and attribute operations also fall into the category. The size of the framework depends on whether the nodes are subdivided.

Brower sniff is out of date, and feature detect is being applied. However, Feature Detection still has limitations. If you want to fix rendering bugs, security policies, or bugs in a browser version, you still need to use browser sniffing. But it should be independent into a module or plug-in, removing the core of the framework.

Currently, all mainstream Event Systems Support event proxy.

Currently, the browser also provides the data-* attribute for data caching and processing, but it is not easy to use and requires further encapsulation of the framework.

Animation engine, unless your framework is backed by a top-level animation framework like script. aculo. us as Prototype. js, it is best to add it as well.

Plug-ins are easy to develop and expand.

Provides asynchronous processing solutions such as Deferred.

Even if a class factory is not provided specifically, there should be a method named extend or mixin that extends the object. Although jQuery does not have a class factory, it has to add one in jQuery UI to show its importance.

Since jQuery came out with a method named noConflict, emerging frameworks have brought this method to survive in a slit.

Many frameworks place great importance on Cookie operations.

Related Article

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.