filmov
tv
Introduction to Javascript Modules: What is a Module and How a Modules works in Javascript

Показать описание
Now we have reached this unit related to ‘Modules’. Surely, you have already heard about Modules in programming, because the concept of Modules and Modular Programming, is no a new technique and it has been around for several years. In fact, this technique has been supported by most of the more popular today programming languages, even with different names, such as:
The term assembly in C# or
Package in Dart or Java
Without the concept of Modules in programming, everything share a global scope in an application, as you may imagine, that approach will cause several problems, such as name collisions, complexity, security concerns, lack of flexibility and portability, that’s why some languages have supported Modular Programming from its creation, for instance, Python(1991), that actually is very popular, another haven’t, but they have included them later, such as Objective C in 2013 or C++ in 2014;
Javascript couldn’t be left behind, and it includes its native modules system in itsECMAScript 2015 specification(ES6), since, Modules are first class citizens in Javascript World.
But What is a Module
But what is a Module? A Module is simply an independent unit of correlated code, a unit or small division, of an application that can be reused throughout all the application or even in another applications,
By the way, these small divisions in javascript could be a single file that includes the required code to execute only one aspect of a desired functionality, In Javascript a module can include objects, functions, classes or even variables that are grouped to solve a desired single functionality.
That concept is the Foundation of Modular Programming technique, an application must be divided into small independent parts, each part must deal with a single aspect of the problem to solve. For instance, in a simple e-commerce app, we must plan our app divided into modules. Each module will be responsible for a particular and single task, as follows:
Store Module
Will fetch and manage the data to build and maintain an online Catalog.
Authentication Module
Will control the flow of users into the app.
Shopping Cart Module
Provide the necessary code to Add and remove products to be purchased by the customers.
Checkout Module
Will manage customers orders and shipping details.
Admin Module
Will facilitate the managing of the catalog, the user’s database and orders details
The term assembly in C# or
Package in Dart or Java
Without the concept of Modules in programming, everything share a global scope in an application, as you may imagine, that approach will cause several problems, such as name collisions, complexity, security concerns, lack of flexibility and portability, that’s why some languages have supported Modular Programming from its creation, for instance, Python(1991), that actually is very popular, another haven’t, but they have included them later, such as Objective C in 2013 or C++ in 2014;
Javascript couldn’t be left behind, and it includes its native modules system in itsECMAScript 2015 specification(ES6), since, Modules are first class citizens in Javascript World.
But What is a Module
But what is a Module? A Module is simply an independent unit of correlated code, a unit or small division, of an application that can be reused throughout all the application or even in another applications,
By the way, these small divisions in javascript could be a single file that includes the required code to execute only one aspect of a desired functionality, In Javascript a module can include objects, functions, classes or even variables that are grouped to solve a desired single functionality.
That concept is the Foundation of Modular Programming technique, an application must be divided into small independent parts, each part must deal with a single aspect of the problem to solve. For instance, in a simple e-commerce app, we must plan our app divided into modules. Each module will be responsible for a particular and single task, as follows:
Store Module
Will fetch and manage the data to build and maintain an online Catalog.
Authentication Module
Will control the flow of users into the app.
Shopping Cart Module
Provide the necessary code to Add and remove products to be purchased by the customers.
Checkout Module
Will manage customers orders and shipping details.
Admin Module
Will facilitate the managing of the catalog, the user’s database and orders details
Комментарии