Modules and Namespaces
The two main practices of this chapter are Modules and Namespaces, which are used together in order to structure and organize our code. We will first analyze the main concept of Modules that is code encapsulation and right after this, we will proceed to Namespacing, which is used to logically organize an implementation.
Encapsulating internal parts of an implementation
While developing a large-scale and complex web application, the need for a well-defined, structured architecture becomes clear from the beginning. In order to avoid creating a spaghetti code implementation, where different parts of our code call each other in a chaotic way, we have to split our application into small, self-contained parts.
These self-contained pieces of code can be defined as Modules. To document this architecture principle, Computer Science has defined concepts such as Separation of Concerns, where the role, operation, and the exposed API of each Module should be strictly defined and focused...