- Modular Programming with JavaScript
- Sasan Seydnejad
- 432字
- 2021-07-14 10:56:45
A real-life example of modules
Let's consider a familiar modular system. You are most likely reading this book in a place that has electricity and there are many electric outlets in the walls surrounding you. This system enables you to plug in various electrical devices into the outlets and each one of these devices is designed to do a very specific task.
Consider the electrical devices that are plugged into some of these outlets: microwaves, electric kettles, washers, dryers, and so on.
None of these devices care if they are plugged into the electrical outlet in your house or your neighbor's house. They are designed to do their specific task and functionality when they are plugged in and when the power is on, regardless of whose house they are in.
Our application modules should follow the same philosophy. This means, regardless of where in the application they are plugged in and even regardless of what application they are plugged into, they should do their specific task and only their specific task.
Also, in exactly the same way that an electrical device can easily be unplugged from the wall outlet, a code module should be designed in such a way that it can easily be decoupled and removed from your application.
Furthermore, as the removal of one electrical device has no impact on the functionality of other devices that are plugged into your electrical system, the removal of a code module or a series of code modules from your application should not have any effect on the functionality of the other parts of your application.
This decoupling should also have no effect on the application as a whole, other than perhaps just losing the specific functionality that was provided by that particular module or group of modules in your application.
In this book, we will explore how creating modules will help in designing better specialized code pieces that can easily be plugged into and unplugged from our applications. We will also see how modular architecture provides for a more robust and flexible application as a whole.
We will discover how this kind of architectural approach leads to huge advantages in many aspects of our application fundamentals such as code usability, maintainability, testability, and many more.
I hope now you are curious enough to at least consider modular programming in general and JavaScript modular programming in particular as a possible approach for your future application design.
In further chapters, we will apply the same principles that we discussed regarding electrical outlets and appliances to our code modules, in both the design and implementation phases.
- 基于粒計算模型的圖像處理
- Flutter開發實戰詳解
- JavaScript 從入門到項目實踐(超值版)
- 算法基礎:打開程序設計之門
- 技術領導力:程序員如何才能帶團隊
- RTC程序設計:實時音視頻權威指南
- Flux Architecture
- Java EE 7 Performance Tuning and Optimization
- 移動界面(Web/App)Photoshop UI設計十全大補
- Natural Language Processing with Java and LingPipe Cookbook
- 創意UI:Photoshop玩轉APP設計
- Learning JavaScript Data Structures and Algorithms(Second Edition)
- Java EE架構設計與開發實踐
- 測試工程師Python開發實戰
- Mastering React Test:Driven Development