A brief talk on JavaScript Framework Classification _ Basic knowledge

Source: Internet
Author: User
Tags extend mootools

The current JavaScript framework can be divided into 5 classes, if it is divided from internal architectures and concepts.

1th Kind

A namespace-oriented class library or framework appears. such as creating an array with the new array (), generating an object with the new objects (), the full Java style, so that we can at the root of an object, and constantly add object attributes or Level two object properties to organize the code, Pyramid-like Horst folded up. Masterpiece such as the early Yui and ext.

2nd Kind

The emergence of a class-oriented factory-led framework, such as the famous prototype, as well as MooTools, Base2, Ten. They are basically in addition to the most basic namespaces, other modules are a class factory derived from the class object. In particular, MooTools 1.3 encapsulates all types into type types.

3rd Kind

It is a selector-oriented framework represented by jquery, the whole frame or library body is a special kind of array object, convenient to set operation-because the selector is usually selected to n element nodes, so it is processed together. jquery contains a few great things: "No new instantiation" technology, $ (expr) is to return an instance, do not need to explicitly new out; get-a-all access rule: Data caching system. This allows you to replicate the node's events. In addition, Iife (immediately-invoked Function Expression) was also unearthed.

4th Kind

Is the framework that is concatenated with the loader, all of which have multiple JavaScript files, and each JavaScript file is written in a fixed rule. One of the most famous is AMD. Modularity is a sign that JavaScript is moving toward industrialization. The first of the many "golden rules" listed in the UNIX programming art is the module, which says, "The only way to write complex software that is not to be a failure is to combine several simple modules with well-defined interfaces, so that most problems only occur locally, Then there is hope to improve or optimize the local, without affecting the whole body. Many internal framework of enterprise adopt this kind of architecture basically, such as Dojo, YUI, Kissy, qwrap and Mass.

5th Kind

is a mv* framework with a well-defined layered architecture. The first is JavaScript MVC (now called Canjs), Backbonejs, Spinejs, and then more in line with the actual front-end MVVM framework, such as knockout, Ember, Angular, Avalon, Winjs. In the MVVM framework, the original DOM operation is replaced by declarative binding, which is handled by the framework, and the user only needs to focus on the business code.

The following is a conclusion about the characteristics of the framework.

Operations on basic data types are fundamental, such as jquery, which provides trim, CamelCase, each, map, and so on, while intrusive frameworks such as prototype.js add Camelize to the prototype.

Type of determination is essential, the common form is the ISXXX series.

Selectors, Domready, Ajax are standard for modern frameworks.

Dom operation is the most important, the traversal of the node, the operation of the style, attribute operation also belongs to its category, whether the subdivision is to see the size of the framework.

Brower sniff is obsolete and feature detect is being applied. However, feature detection has its limitations, and browser sniffing is used if you are correcting bugs, security policies, or some bugs for a browser version. But it should be standalone into a module or plug-in that removes the core of the frame.

Event agents are now supported by the mainstream event system.

Data caching and processing, the current browser also provides data-* properties for this work, but not easy to use, the need for further encapsulation of the framework.

Animation engine, unless your frame is backed by a top-level animation frame like script.aculo.us, it's best to add prototype.js.

Easy development and extensibility of plug-ins.

Provides solutions such as deferred to handle asynchrony.

Even if a class factory is not specifically provided, there should be a method named extend or mixin to extend the object. jquery does not have a class factory, but it also has to add one in the jquery UI, which can be seen as important.

Since jquery came out with a method called Noconflict, the emerging framework takes this approach in order to survive in a slit.

Many frameworks attach great importance to 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.