What’s the difference between dependency inversion and dependency injection? Dependency injection is a design pattern that splits creation of objects from their usage. Dependency inversion is a design principle that promotes using abstract classes and interfaces to better separate code. Watch this video to see a few practical examples in Python, and how these concepts help you write nice code that’s easy to test.
✅ Write cleaner code with Sourcery: https://sourcery.ai/?utm_source=YouTube&utm_medium=aff&utm_campaign=ArjanCodes
My camera gear:
📷 Sony A7C - https://amzn.to/3aShCtw
🎙 Rode Wireless GO - https://amzn.to/3pSLFVU
🎙 Electrovoice RE20 - https://amzn.to/3xQAJ0w
🎙 Sennheiser MKH416 P48 - https://amzn.to/3vOpx2i
🎚 Sound Devices Mix-Pre 3 II - https://amzn.to/3nSOc37
💡 GVM RGB LED light - https://amzn.to/3qRNJid
💡 GVM 100W light with lantern softbox - https://amzn.to/2NuU8lk
☕If you want to support this channel, you can buy me a coffee here: https://www.buymeacoffee.com/arjancodes.
A few interesting links to articles and books:
The code I worked on in this example is available here: https://github.com/ArjanCodes/2021-dependency-injection-inversion.
👍 If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!
💬 Join my Discord server here: https://discord.arjancodes.com
0:20 What is a dependency?
1:10 Dependency injection
1:36 Dependency inversion
2:03 Example code
3:22 Example unit tests
5:32 Issues with testing
6:37 Applying dependency injection
8:35 Writing the unit tests
11:20 Applying dependency inversion
12:51 Coverage reports and abstract classes
14:16 The power of dependency inversion
14:49 Adding another authorizer
15:44 Adding tests for the Robot authorizer
DISCLAIMER - The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!