I think dependency injection to achieve the same thing without using inheritance. For example, I can assign self.serializer = Serializer() at def __init__(). Am I thinking correctly? When should I decide to use dependency injection vs mixins and vice versa?
Dependency injection is the technique to inject objects into other objects. Could it be you mean when to favor composition over inheritance? In this video, I show a scenario where DI and composition work very well: ruclips.net/video/BdMO1IR-800/видео.html
Here is a youtube video: ruclips.net/video/VqeBgD5TuAQ/видео.html on the Open Closed Principle and if you want to support me, you can enroll in my S.O.L.I.D. course on Udemy: pythonforeveryone.com/python-solid-online-training.html
Yep, that is a problem of dynamically typed languages. There is no guarantee that attributes will be present. If you want to satisfy the type checker, you could use base classes or protocols.
short and to the point. great work
Thank you very much for the video.
You are welcome!
Great!
thanks!
I think dependency injection to achieve the same thing without using inheritance. For example, I can assign self.serializer = Serializer() at def __init__(). Am I thinking correctly? When should I decide to use dependency injection vs mixins and vice versa?
Dependency injection is the technique to inject objects into other objects. Could it be you mean when to favor composition over inheritance? In this video, I show a scenario where DI and composition work very well: ruclips.net/video/BdMO1IR-800/видео.html
Can you make video abou SOLID principles?
Here is a youtube video: ruclips.net/video/VqeBgD5TuAQ/видео.html on the Open Closed Principle and if you want to support me, you can enroll in my S.O.L.I.D. course on Udemy: pythonforeveryone.com/python-solid-online-training.html
I'm struggling with IDE typing errors when a mixin access to properties it doesn't posses (yet).
Any advice on how to handle that properly? Thank you!
Yep, that is a problem of dynamically typed languages. There is no guarantee that attributes will be present. If you want to satisfy the type checker, you could use base classes or protocols.