www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is overriding dependency prodivers considered bad practice?

reply Victor Porton <porton narod.ru> writes:
 From https://stackoverflow.com/q/54847333/856090 :

I am reimplementing something like Python [Dependency 
Injector][1] in D programming language. I want to build a pure 
dependency injection framework for D.

Is [overriding of providers][2] considered bad practice? It seems 
that overriding of providers is clearly a nonlocal dependency and 
nonlocal dependencies are usually considered a bad practice by 
OOP theoretics.

So should I or should I not implement overriding of providers in 
my pure dependency injection framework for D?

   [1]: http://python-dependency-injector.ets-labs.org/
   [2]: 
http://python-dependency-injector.ets-labs.org/providers/overriding.html
Feb 24 2019
parent reply Alexandru Ermicioi <alexandru.ermicioi gmail.com> writes:
On Sunday, 24 February 2019 at 10:36:40 UTC, Victor Porton wrote:
 From https://stackoverflow.com/q/54847333/856090 :

 I am reimplementing something like Python [Dependency 
 Injector][1] in D programming language. I want to build a pure 
 dependency injection framework for D.

 Is [overriding of providers][2] considered bad practice? It 
 seems that overriding of providers is clearly a nonlocal 
 dependency and nonlocal dependencies are usually considered a 
 bad practice by OOP theoretics.

 So should I or should I not implement overriding of providers 
 in my pure dependency injection framework for D?

   [1]: http://python-dependency-injector.ets-labs.org/
   [2]: 
 http://python-dependency-injector.ets-labs.org/providers/overriding.html
Just wondering, did you check existing implementations of dependency injection frameworks, such as https://code.dlang.org/packages/aedi or https://code.dlang.org/packages/poodinis before trying to implement yet another one? If you did check them, I'm wondering, what deficiencies in those implementations you found that made you to attempt to create yet another DI framework? Dlang also has a page with a list of existing DIs https://wiki.dlang.org/Dependency_Injection_Containers. Thank you, Alexandru.
Feb 24 2019
parent reply Victor Porton <porton narod.ru> writes:
On Sunday, 24 February 2019 at 11:37:49 UTC, Alexandru Ermicioi 
wrote:
 Just wondering, did you check existing implementations of 
 dependency injection frameworks, such as 
 https://code.dlang.org/packages/aedi or 
 https://code.dlang.org/packages/poodinis before trying to 
 implement yet another one?
 If you did check them, I'm wondering, what deficiencies in 
 those implementations you found that made you to attempt to 
 create yet another DI framework?

 Dlang also has a page with a list of existing DIs 
 https://wiki.dlang.org/Dependency_Injection_Containers.
I checked this page. I want a PURE dependency injection framework. Existing ones are impure.
Feb 24 2019
parent reply Alexandru Ermicioi <alexandru.ermicioi gmail.com> writes:
On Sunday, 24 February 2019 at 12:44:14 UTC, Victor Porton wrote:
 On Sunday, 24 February 2019 at 11:37:49 UTC, Alexandru Ermicioi 
 wrote:
 Just wondering, did you check existing implementations of 
 dependency injection frameworks, such as 
 https://code.dlang.org/packages/aedi or 
 https://code.dlang.org/packages/poodinis before trying to 
 implement yet another one?
 If you did check them, I'm wondering, what deficiencies in 
 those implementations you found that made you to attempt to 
 create yet another DI framework?

 Dlang also has a page with a list of existing DIs 
 https://wiki.dlang.org/Dependency_Injection_Containers.
I checked this page. I want a PURE dependency injection framework. Existing ones are impure.
I have a bit of trouble understanding of what do you mean by pure DI framework. Would you mind explaining a bit what do you mean by that? Thank you, Alexandru.
Feb 24 2019
parent Victor Porton <porton narod.ru> writes:
On Sunday, 24 February 2019 at 13:22:12 UTC, Alexandru Ermicioi 
wrote:
 I have a bit of trouble understanding of what do you mean by 
 pure DI framework. Would you mind explaining a bit what do you 
 mean by that?
I mean a framework for implementing pure dependency injection: https://hackernoon.com/you-dont-need-a-dependency-injection-container-10a5d4a5f878 In the above article it is recommended to use no framework at all, but a framework is still useful to make such things as for example singletons.
Feb 24 2019