2. Coupling between modules occurs when one
module directly references another module. In
other words, one module “knows” about another
module.
The problem: Coupling
3. The solution: The OO design principles
“Depend upon Abstractions. Do
not depend upon concretions.”
“Favor 'object composition' over
'class inheritance'.”
9. Inversion of Control (IoC) and IoC containers
● Inversion of control is used to increase modularity of the program
and make it extensible and flexible.
● The question is: "what aspect of control are we inverting?" The
IoC container takes the control over the object composition.
11. inversify.config.ts
The modules are unaware of each other but the
IoC container is aware of all the modules in the
application.
Coupling takes place in one unique place.
13. Declaring kernel middleware
The middleware is an extension point
for InversifyJS. It allows developers to
create plugins for InverifyJS.
The internal InversifyJS process:
1. Annotation phase
2. Planning phase
3. Middleware (optional)
4. Resolution phase
5. Activation handlers (optional)
15. Using abstractions: String literals
● We use string literals to represent interfaces at runtime
● String literals can lead to naming collisions be careful!
16. Using abstractions: Symbols
● Symbols helps us to avoid naming collisions
● Symbols might be generated by the TypeScript compiler in the future.
This would eliminate the need for manual annotations when using
interfaces!
17. Controlling the scope of the dependencies
The IoC container takes the control over the lifecycle of the dependencies.
18. Let’s take a look to some of the
InversifyJS features!