Decouple code with DEPENDENCY INJECTION in Python

preview_player
Показать описание
This video shows how to decouple your code by using dependency injection in Python. It also shows the benefits of dependency injection by replacing storage logic with minimal risk of breaking stuff.

C H A P T E R S
0:13 Setting up the project
0:43 The window class
2:04 Window and file logic is coupled
2:20 Extract the save logic
2:40 Decouple by injecting storage object
4:25 Benefits of the decoupled code
4:47 Replace file storage with database storage

M Y O N L I N E T R A I N I N G

#dependencyinjection #programming #python
Рекомендации по теме
Комментарии
Автор

This is how programming (and any other topic) should be presented. Brilliant explanation.

rodmallen
Автор

I can't begin to express how wonderful this instructional video is. Though short, it perfectly illustrates DI from start to finish with a clear example of the benefit without using long verbose code. This video, which took me 30 min to get through with code along and note taking is better than anything I've seen written to date. Nevermind that the Window class could be potentially split more, that is just splitting hairs. The video is about DI and clearly demonstrates it. You've got a new sub and buyer of the udemy course!

machinimaaquinix
Автор

this is save my time, thanks a lot sir

sonyalamsyah
Автор

dependency injection vs composition what is the difference.. please make a video

KASANITEJ
Автор

Why not use methods instead of classes? The savetext method can be passed to the object and by default could be put to the savetext method right there.

aoeu
Автор

I think your Window() class violates the first principle of SOLID. It has many responsabilities

And-vgij
Автор

Didn't explain the problem thoroughly...

Good video overall

chriskeo
Автор

you get the concept wrong. Window class still depends on TextFile class's fucntion. if TextFile change its save_text function name, it will yield error in Window class.

rafathasan
Автор

You can't fool me, I know you're Dutch as fuck

AwesomeAsh
Автор

there is no need to create a class for saving, just use a function.
A class with one just method, which is instantiated just to call the method and then thrown away, is a clear sign that the coder does not yet understand Python and the capabilities of dynamic languages.

alexd
join shbcf.ru