Framework classification and main functions of javascript framework design

  • 2020-06-19 09:39:28
  • OfStack

The CURRENT JavaScript framework can be divided into five categories from the perspective of internal architecture and philosophy.

1 kind is a namespace as the guidance of the libraries or frameworks, if you create an array with new Array (), to generate an object with new Object (), completely java style, therefore, we take a 1 object with, constantly adding objects and 2 levels of object properties for it to organize your code, like the pyramids up, early representative YUI EXT (so, not energetic companies still use them)

The second is a factory-like oriented framework. Most notably, Prototype, mootools, Base2, and Ten are basically a class object derived from a class factory, except for the most basic namespace. In particular, mootools1.3 encapsulates all types as Type types.

The third is the selector-oriented framework represented by jQuery. The whole framework or library body is a special class array object, which is convenient for the aggregation operation (because the selector 1 has selected N element nodes), so 1 and processing. jQuery has a few great things about it:

"No new instantiation" technology, $(expr) is to return 1 instance, do not need explicit new out;
get first set all access rules;
Data caching system. This allows you to assign node events.
IIFE was also unearthed

The fourth is the frame in which the loaders are concatenated, each of which has a complex number of javascript files, each of which is written in a fixed rule. The most famous of these is AMD. Modularity is the symbol of javascript's industrialization. "The only way to write complex software that will not be wiped out is to have a clearly defined interface and combine several modules together. In this way, most problems will only occur in the local area. Many enterprise internal frameworks basically adopt this architecture, such as Dojo,YUI, Kissy,qwrap,mass,(requirejs,Seajs) and so on.

5 kinds, have clear layered architecture is MV *, the first is javascript MVC, (now called Canjs), backbone js and spinejs, then more accords with the practice of the front-end MVVM framework, such as, knockout, emberm, angular, avalon, winjs. In the MVVM framework, the original DOM operation is replaced by declarative binding, which is handled freely by the framework, and the user only focuses on the business code.

The main functions of the javascript framework

jQuery framework class library module partition of the main basis in github source code, is essentially a module 1 javascript file, jQuery1 began to focus on DOM operation ideas 1 is right, then continuously on the compatibility, the performance was improved, after years of development, jQuery large plug-in and perfect BUG submit channels, perfecting makes itself

The early king of Prototype, it was divided into four parts.

Language extension
DOM extension
Ajax part
The new version USES other methods to implement the original functions

Prototype.js's language extension covers a wide range of basic data types and "classes" borrowed from the language. Among them, Enumerable is just a common method package, ObjectRange, PeriodicalExecuter, Templat are produced with Class class factory (from community contributions).

mootools has survived the backlash against prototype extensions thanks to its elegant design and the availability of quality add-ons on its official website.

Rightjs: Another framework on prototype extension, MochiKit 1 Python style framework, 10 points unique, can be in the top 10 of the framework.
Ten: The Javascript framework of Hatena, developed by amachang and influenced by ES114en. js, is the earliest example of a framework named after space. mass Framework: An ES118en-style framework for large module development.

After a detailed comparison, we can easily draw conclusions about the following framework characteristics

 Operations on basic data are fundamental, such as jQuery To provide the trim camelCase each map Wait for a method, Prototype.js Such intrusive frameworks are added to the prototype camelize Methods such as 
 The type of the decision than not less, the common form is jsXXX A series of 
 Selector, domReady Ajax It is standard for modern frames 
DOM Operation is the most important, node traversal, style operation, attribute operation is also its category 
 The main event systems now support event brokers 
 Data caching and processing, the current browser also support data- Properties operate, but are difficult to use and require framework encapsulation 
 Animation engine 
 Easy development and extensibility of plug-ins 
 Provide such as Deferred This handles asynchronous solutions 
 Even if not specifically provided 1 A class factory should also exist 1 called extend or mixin Method to extend the object. jQuery Although there is no class factory, but in jQuery UI Also has to increase 1 We can see its importance. 
 Since the jQuery Come out 1 called noConflict ", the emerging framework with this method, in order to survive in the slit. 
 Many frameworks are very important Cookie Operation. 

This is the end of this article, I hope you enjoy it.

Related articles: