Today, Guiyang Beida Jade Bird/Let's analyze the benefits of web front-end modular programming.
First, the understanding of modularity 1 What is a module? Encapsulate a complex program into several blocks (files) according to certain rules (specifications) and combine them together; The internal data and implementation of the block are private, but some interfaces (methods) are exposed to the outside to communicate with other external modules.
2. Modular evolution process global function mode: different functions are encapsulated into different global functions; Coding: encapsulating different functions into different global functions; Problem: The global namespace is polluted, which easily leads to naming conflicts or data insecurity, and there is no direct relationship between module members.
3. The advantages of modularization are avoiding naming conflicts (reducing namespace pollution), better separation, higher reusability and higher on-demand maintainability. 4. There is a problem after introducing multiple scripts. We have to rely on multiple modules first, so we will send multiple requests, resulting in too many requests.
Dependency is vague. We don't know what their specific dependencies are, that is, because we don't know their dependencies, it is easy to make mistakes in the loading order.
The above two reasons are difficult to maintain, leading to maintenance difficulties, and it is likely that the situation will lead to serious problems in the project.