Dependency injection is a technique in which an object receives other objects it depends on.
It is actually one form of the broader technique inversion of control.
🧵👇🏻
1⃣ What is it?
Dependency injection is a technique where every other object (service) an object (client) depends on is injected from the outside.
So instead of simply instantiating everything on its own, a class relies on it being passed in from the outside.
You can also view it this way:
Imagine your favorite RPG character could only wear the equipment they started with. No way to change the equipment or the look of your character's equipment from the outside.
Although I am not a data scientist by any means, I was recently asked what knowledge of math someone would need to be able to efficiently get into the field.
Well, I researched a little and came up with the following course track, starting with the basics.
🧵👇
Calculus 1 will cover a lot of the basics, relevant especially to optimization problems which are quite common in data science.
The Dependency Inversion Principle is a part of SOLID, a mnemonic acronym which bundles a total of 5 design principles.
It is often associated with clean code.
But what exactly is it, is it important to you, should you even care?
🧵👇
1⃣ What does it state?
It states:
Modules that encapsulate high-level policy should not depend upon modules that implement details. Rather, both kinds of modules should depend upon abstractions.
This may sound a little complicated, but you can break it up, as follows:
1. High-level modules should not depend on low-level modules. Both should depend on abstractions (e.g., interfaces).
2. Abstractions should not depend on details. Details (concrete implementations) should depend on abstractions.