Dependency INVERSION vs Dependency INJECTION in Python

Dependency INVERSION vs Dependency INJECTION in Python

ArjanCodes

3 года назад

161,741 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@muralir8504
@muralir8504 - 17.05.2022 21:00

best tutorial for advance topics

Ответить
@NilenduDasnilendudas
@NilenduDasnilendudas - 20.05.2022 14:16

Dependency inversion is the process of introducing a new layer between objects in the form of abstract class to reduce dependancy between objects directly and also means that these can be replaced with their subtypes. - This is hands down the most simple definition I have ever heard. Thank you so much.

Ответить
@valshaped
@valshaped - 22.05.2022 12:06

Those are authenticators (authN), not authorizers (authZ). The user has the phone, and enters the 6 digits, so you know they're the user.
Knowing the user is who you think they should be is only half the battle! You have to get consent (authoriZation)!

Ответить
@Nayanexx
@Nayanexx - 02.06.2022 00:54

I still don't understand Dependency Injection

Ответить
@Korcari1
@Korcari1 - 20.06.2022 05:48

Thanks!

Ответить
@RichardVodden1
@RichardVodden1 - 20.06.2022 08:11

This is a wonderfully clear explanation of a potentially very complex topic. Thank you very much. I tend to prefi my instance variables with _ (e.g. self.autborizer) so that mypi will warn if I call it from outside the class. This avoids accidentally introducing coupling through injected components.

Ответить
@dariuszspiewak5624
@dariuszspiewak5624 - 17.07.2022 18:35

Arjan, is it not more convenient to use pytest instead of unittest? Seems to be simpler and (maybe?) more flexible?

Ответить
@rusbelbermudez238
@rusbelbermudez238 - 24.07.2022 18:17

Really nice videos I have learned a lot.

Ответить
@alexd7466
@alexd7466 - 06.08.2022 01:02

That is true in Java but in Python we have other ways to solve this issue.

Ответить
@michalbotor
@michalbotor - 19.08.2022 20:26

spring
oh, sorry, wrong channel

Ответить
@hakimbhd9736
@hakimbhd9736 - 24.08.2022 13:56

You are the best 🤩

Ответить
@_hello_5346
@_hello_5346 - 10.09.2022 05:31

This is great, thank you.

Ответить
@artist6000ish
@artist6000ish - 11.09.2022 02:28

This dude it got it backwards.

Ответить
@wing-keiwong9418
@wing-keiwong9418 - 11.09.2022 03:46

It looks like generate_sms() is not called as part of the new code. How will you retractor the codes so it is included when the class authorise_sms is used and excluded while authorise_robot is used?

Ответить
@WMRamadan
@WMRamadan - 12.09.2022 23:47

Is there a blog post explaining dependency inversion in relevance to file structure?

Ответить
@SurajAdhikari
@SurajAdhikari - 09.11.2022 05:15

Nice video. One important detail you could add for tests is that instead of instantiating an actual object we normally create a mock object which inherits the abstract class. The mock implementation obviously will have dummy return values. But that will highlight the true power of dependency injection in lieu of unit testing.

Ответить
@brianakong7644
@brianakong7644 - 06.12.2022 01:07

Awesome video, explanations, and examples! Thank you!

Ответить
@_general_error
@_general_error - 08.12.2022 00:51

At least learn the script for your videos from good sources. It's "Inversion of Control" or IoC, not "Dependency Inversion". And in fact, you are wrong, you don;t need both for high quality code... maybe in your company... but perr recognition is not what we seek, we seek understanding, right? The correct statement is You'll need follow IoC principles, so you can take advantage if it using DI paradigm.

please, language ;)

Ответить
@geekyboytop
@geekyboytop - 09.01.2023 05:37

Awesome explanation thank you took plenty of notes!

Ответить
@fmictsang8874
@fmictsang8874 - 25.01.2023 07:03

Thanks.

Ответить
@Matt-iy2cf
@Matt-iy2cf - 03.02.2023 01:19

This is inacurate. You don’t understand what dependency inversion is. You said: „without dependency injection there is no dependency inversion”
Dependency inversion is a reversal of the traditional dependency wherby high-level class depends on low-level class. It happens when both low level and high level classes start relying on abstract class and for that to happen you absolutely don’t need dependency injection.

Ответить
@programminginterviewsprepa7710
@programminginterviewsprepa7710 - 04.02.2023 13:14

But how do you inject objects deeper in call hierarchy??

Ответить
@tokero5199
@tokero5199 - 13.02.2023 12:30

I'm new to python, I'm wondering why use an Abstract class for the Authorizer, why not use an interface?

Ответить
@Aldraz
@Aldraz - 07.03.2023 20:27

I wonder if you can use pyproject.toml instead of files like .coveragerc, I think it should be possible and would be nice to have all these settings in 1 file. Anyway, if you didn't make a video about pyproject.toml, I think you should, it is pretty overpowered :)

Ответить
@rolandovillcaarias5112
@rolandovillcaarias5112 - 03.04.2023 16:21

Finally I can see an example to understand DI clearly. Thank you Arjan for your explanation :)

Ответить
@hansdietrich1496
@hansdietrich1496 - 17.04.2023 23:28

pytest FTW!

Ответить
@andyanderson222
@andyanderson222 - 24.04.2023 20:49

I absolutely love this channel! Its pure joy to watch these tutorials! Thanks a lot!

Ответить
@kukuruzayevhenii8764
@kukuruzayevhenii8764 - 05.05.2023 15:46

Thank you! I watched a dozen videos on the topic, but this one not only explained it in the best way, but also felt like a way more complete explanation!

Ответить
@cs-ope
@cs-ope - 22.07.2023 09:57

You're too damn good

Ответить
@k98killer
@k98killer - 06.08.2023 22:55

Dependency inversion is then something like the maxim "couple to interfaces, not implementations".

Ответить
@Roman-kn7kt
@Roman-kn7kt - 08.08.2023 16:23

Awesome!!!

Ответить
@ZanarkandStarplayer
@ZanarkandStarplayer - 21.08.2023 05:40

Is dependency inversion just Dependency Injection + Strategy Pattern?

Ответить
@ddystopia8091
@ddystopia8091 - 28.08.2023 11:06

Dependencie injection is not the only tool for dependency inversion. If you rely on DI too much, then you'll get into mock hell

Ответить
@sloan00
@sloan00 - 31.08.2023 17:04

Can you check subtitle in video? It seems to not support English.

Ответить
@Sidorvm
@Sidorvm - 01.09.2023 19:21

Nice!

Ответить
@edgeeffect
@edgeeffect - 07.09.2023 16:13

As ever, an excellent video but could I just recommend that watchers follow this up with Code Aesthetic's equally excellent Dependency Injection video.

Ответить
@enricoroselino7557
@enricoroselino7557 - 18.10.2023 20:54

so dependency injection is the way to pass a class and inversion is the interface / abstract so the passed class not tied to one specific class. noted, thank you mr arjan

Ответить
@agamemnonc
@agamemnonc - 21.11.2023 12:05

Is this abstract class or "intermediate layer" as you call it an interface? If not, what's the difference between such an abstract class and an interface?

Ответить
@MarcDunivan
@MarcDunivan - 21.11.2023 22:47

OOP brings a whole other level to programming. Much more than watching simple C language tutorials. I can't imaging Oracle bringing these OOP concepts to PL/SQL...or GNU Scheme...? Didn't the industry switch to Data Oriented Programming?

Ответить
@franktaylor7978
@franktaylor7978 - 30.11.2023 02:49

love your channel but you seem to break pep 8 from time to time. or maybe I'm not up to date. e.g. class name with mix of snake case and camel case.

Ответить
@TheBIKEDEALZ
@TheBIKEDEALZ - 01.04.2024 22:35

superb.
what should be the guideline to splitting it properly?

Ответить
@DeKeL_BaYaZi
@DeKeL_BaYaZi - 06.05.2024 14:41

You are the coolest developer ever

Ответить
@grif.n
@grif.n - 03.06.2024 08:23

Is there a reason the PaymentProcessor needs to take an authorizer argument at all instead of there being another process_order method on the Order class which authorizes the user and then takes payment? Is it because payment shouldn't be possible without authorization every time, so the strict usage of authorize inside pay method is necessary?
Would refactoring authorize and pay to happen separately but inside a process_order method also be dependency inversion?

Ответить
@TheDefirion
@TheDefirion - 03.08.2024 00:10

If I understood this correctly an extra layer of abstraction is created between the Authorizer subclasses and the PaymentProcessor, where do we define which Authorizer is used? Am I missing something

Ответить
@ojosedirceu
@ojosedirceu - 14.10.2024 22:52

Finally clarified the differences between them, Thank You Arjan!

Ответить
@ArjanCodes
@ArjanCodes - 14.05.2021 15:10

Finally upgraded to better microphones for this video!

Ответить