We have learned how to work with application dependencies and third-party dependencies. We will now learn about the dependency inversion and extend what we learned in the previous chapter about the dependency inversion principle.
Managing dependencies in OOP
Dependency injection versus dependency inversion
Many articles use the terms dependency injection and dependency inversion as if their meanings were identical, but they are two very different concepts.
The following example declares a class named Ninja and a class named Katana. The Ninja class has a dependency on the class Katana:
class Katana { public tryHit(fromDistance: number) { return fromDistance <= 2; } } class Ninja { public constructor...