What is JavaScript modularity

Source: Internet
Author: User
Tags define include

Now backbone, Emberjs, Spinejs, Batmanjs and other MVC frameworks have come to the attack. Commonjs, AMD, Nodejs, Requirejs, Seajs, Curljs and other modular JavaScript are coming. Web front-end has evolved into a large front-end, the Web front-end development faster.

1 Let's see what modularity is?

Modularization is a method of separating the system into independent functional parts, which can be divided into separate functional parts, which strictly define the transparency between module interfaces and modules. Modules in JavaScript are more common in some C, PHP, and Java:

Unity3d Script http://www.unitymanual.com

C uses include. h files, PHP uses require_once to include. php files

Java Import package using Import

There are modular ideas in this.

2 The advantages and disadvantages of modularity:

A> Advantages:

Maintainability

1. Flexible architecture, focus separation

2. Easy to combine and decompose between modules

3. Facilitate single module function debugging, upgrade

4. Multi-person collaboration and mutual interference

Testability

1. Can be divided into unit test

B> Disadvantages:

Performance loss

1. System layering, call chain will be very long

2. Communication between modules, sending messages between modules can be very performance-consuming

3 Recent projects are also useful for modularity, using SEAJS, but when referencing to Jquery,jquery easyui/or jquery UI components, it is possible to use a lot of jquery plug-ins, so that if you implement a very complex interaction, there will be a lot of dependencies between modules, Using the Define () method to introduce modules will be a lot, do not know what is the best way?

4) Attached:

Cohesion degree

Cohesion refers to the internal implementation of the module, which is the natural extension of the concept of information hiding and localization, which indicates the close degree of the integration of each component within a module. The benefits are also obvious, and it is much easier to read the relevant tasks when grouped. Design should be as much as possible to improve the cohesion of the module, so as to obtain higher module independence.

Coupling degree

Coupling degree refers to the measurement of the degree of association between modules. The degree of coupling depends on the complexity of the interface between modules, the position of the module entering or calling. In contrast to cohesion, a loosely coupled system should be pursued as far as possible in design.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/

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.