What is javascript modularization and its advantages and disadvantages _ basic knowledge

Source: Internet
Author: User
Modularization is a way to separate the system into independent functional parts, which can be divided into independent functional parts, strict definition of module interfaces and transparency between modules are now under attack by MVC frameworks such as backbone, emberjs, spinejs, and batmanjs. CommonJS, AMD, NodeJS, RequireJS, SeaJS, curljs, and other modular JavaScript. The web Front-end has evolved into a large front-end, and the development speed of the web Front-end is growing fast.

1) Let's see what is modularity?
Modularization is a method to separate the system into independent functional parts. It can divide the system into independent functional parts and strictly define the module interfaces and transparency between modules. Javascript modules are common in C, PHP, and java:

Use include to include. H files in c; Use require_once to include. php files in php
Java import package using import
There are modular ideas in this process.

2) Advantages and Disadvantages of modularity:

A> advantages:
Maintainability
1. flexible architecture and focus Separation
2. convenient combination and decomposition between modules
3. Easy debugging and upgrade of Functions of a single module
4. multi-person collaboration does not interfere with each other
Testability
1. severable unit test

B> disadvantages:
Performance Loss
1. hierarchical system, long call chain
2. Inter-module communication. Sending messages between modules consumes a lot of performance.

3) modularity is also useful in recent projects.. Seajs is used. However, when jquery, jquery easyui/or jquery UI components are referenced, many jquery plug-ins may be used. In this way, if a complicated interaction is implemented, there will be a lot of dependencies between modules, and there will be a lot of introduction modules using the define () method. I wonder if there are any good methods?

4) Appendix:
Cohesion
Cohesion refers to the internal implementation of a module. It is a natural extension of the concepts of information hiding and localization. It marks the closeness of various components in a module. It is also obvious that it is much easier to group related tasks and then read them. The module cohesion should be improved as much as possible during the design, so as to obtain high module independence.

Coupling Degree
Coupling Degree refers to the measurement of the degree of association between modules. The coupling degree depends on the complexity of the interfaces between modules, and the position of the modules to enter or call. In contrast to cohesion, we should try to pursue a loosely coupled system during design.
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.