Javascript Framework Design: Framework Classification and main functions, javascript framework

Source: Internet
Author: User
Tags mootools

Javascript Framework Design: Framework Classification and main functions, javascript framework

Based on the internal architecture and concept, the current JavaScript framework can be divided into five categories.

The first is a namespace-oriented class library or framework.If you create an Array using new Array () and generate an Object using new Object (), the full java style. Therefore, we take an Object as the heel, constantly add objects and second-level object attributes for it to organize code, such as pyramid-like barriers, early representatives of YUI, EXT (so, not dynamic companies are still using them)

The second is a factory-oriented framework.. The famous ones include Prototype, mootools, Base2, and Ten. In addition to the most basic namespaces, the other modules are class objects derived from the class factory. In particular, mootools1.3 encapsulates all types into the Type.

The third type is the selector-oriented framework represented by jQuery.The entire framework or library body is a special class array object, which facilitates the set operation (because the selector selects N element nodes at once), so it is processed together. JQuery has a few amazing things:

"No new instantiation" technology, $ (expr) is to return an instance, do not explicitly new out;
Get first set all access rules;
Data Cache System. In this way, you can assign values to node events.
IIFE has also been discovered

The fourth type is the frame in which the loader is connected in series.It has multiple javascript files, and each javascript file is written with fixed rules. AMD is the most famous among them. Modularization is a sign of javascript's industrialization. "The only way to write complex software is to define clear interfaces and combine several modules, most problems only occur in the local area, so we still want to improve and optimize the local area without affecting the whole body." Many enterprise internal frameworks basically adopt this architecture, such as Dojo, YUI, Kissy, qwrap, mass, (requirejs, Seajs.

The fifth type is MV with a clear layered architecture *,First, javascript MVC (now called Canjs), backbone. js, and spinejs, and then more in line with the actual front-end MVVM framework, such as knockout, emberm, angular, aveon, winjs. In the MVVM framework, the original DOM operations are replaced by declarative binding and are free to handle by the Framework. Users only focus on business code.

Main functions of the javascript framework

The module division of the jQuery framework class library is mainly based on the source code of github. Basically, it is a module and a javascript file. jQuery initially focused on DOM operations, in the future, we will continue to improve the compatibility and performance. After years of development, jQuery's huge plug-ins and complete BUG submission channels will make it constantly improved.

Prototype. jsThe early king was divided into four parts.

Language extension
DOM Extension
Ajax Section
Discard part. The new version uses other methods to implement the original functions.

Prototype. js provides a wide range of language extensions, including basic data types and "classes" from language references ". Enumerable is only a common method package. ObjectRange, PeriodicalExecuter, and Templat are produced by Class factories (contributed by the community ).

MootoolsBecause the API design is very elegant, its official website has many high-quality plug-ins, so it is not in the tide of prototype extension opposition.

Rightjs:Another prototype extension framework, MochiKit, a Python-style framework, is very unique and can enter the top 10 frameworks.
Ten: The Javascript framework of Hatena, developed by amachang and influenced by Prototype. js, is the earliest framework model named by space;Mass Framework:A jQuery framework designed for big module development.

After detailed comparison, we can easily draw conclusions about the following framework features:

Operations on basic data are the basis, such as trim camelCase each map and other methods provided by jQuery, Prototype. js and other invasive frameworks add methods such as camelize to the prototype to determine the ratio is indispensable, the common form is the jsXXX series selector, domReady Ajax is the standard DOM operation of modern frameworks is the top priority, node traversal, style operations, and attribute operations also fall into its category. Currently, mainstream Event Systems Support caching and processing of event proxy data. Currently, browsers also support data-attribute operations, but it is not easy to use. It requires the framework to encapsulate the ease of Development and scalability of the animation engine plug-in to provide a solution for asynchronous processing such as Deferred, even if it does not provide a class factory, there should also be a method named extend or mixin to expand 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.

The above is all the content of this article. I hope you will like it.

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.