What is JavaScript modularity and what are the pros and cons of

Source: Internet
Author: User

Modularization is a method of separating the system into independent functional parts, which can divide the system into independent functional parts, define the module interface strictly, and have the transparency between the modules.

Now backbone, Emberjs, Spinejs, BATMANJS and other MVC framework attack. CommonJS, AMD, NodeJS, Requirejs, Seajs, Curljs and other modular JavaScript are on the go. Web front-end has evolved into a large front end, the development of the Web front-end faster.

1) Let's see what is modularity?
Modularization is a method of separating the system into independent functional parts, which can be divided into independent functional parts, and the module interface is strictly defined and the module is transparent. The modules in JavaScript are more common in some C, PHP, and Java:

Use include. h files in C, PHP using require_once contains. php files
Java Importing packages using Import
There are modular ideas in this.

p) advantages and disadvantages of modularity:  

a> Advantages:
maintainability
1. Flexible architecture, focus separation
2. Easy to assemble and decompose between modules
3. Convenient debugging and upgrading of single module function
4. Multi-person collaboration and non-interference
testability
1. Can be divided into unit testing

b> Disadvantages:
Performance Loss
1. System layering, call chain will be very long
2. Inter-module communication, sending messages between modules can be very performance-consuming

3) The most recent projects are also useful in modular, using SEAJS, but when referencing to the Jquery,jquery easyui/or jquery UI components, there are many jquery plugins that may be used, so there is a lot of dependencies between modules when implementing a very complex interaction. Using the Define () method to introduce modules will be a lot, do not know what good method?

4) Attached:
Internal cohesion Degree
Cohesion refers to the internal implementation of the module, which is a natural extension of the concept of information hiding and localization, it marks the internal components of a module of the integration of the degree of tightness. The benefits are also obvious, and it's much easier to read the relevant tasks after grouping them. The design should increase the cohesion of the module as much as possible, thus obtaining a high degree of module independence.

Coupling degree
Coupling degree is a measure of the degree of association between modules. Coupling depends on the complexity of the interface between the modules, the location of the module to enter or call, and so on. In contrast to cohesion, a loosely coupled system should be pursued as much as possible at design time.

What is JavaScript modularity and what are the pros and cons of

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.