Most voted "dependency-injection" questions
Dependency Injection is a development standard that aims to reduce the coupling between components of an application by dynamically injecting the dependencies it needs to work rather than programmatically defining them.
Learn more…92 questions
Sort by count of
-
89
votes2
answers8108
viewsWhat are the differences between Dependency Injection and Control Inversion?
Sometimes it feels like we’re talking about the same thing (of course, it’s not) when these concepts are being used. What’s the real difference between them? When using one or the other?
pattern-design software-engineering dependency-injectionasked 10 years, 5 months ago Maniero 444,682 -
71
votes4
answers25411
viewsWhat is addiction injection?
I have heard a lot about addiction injection. The question is: How, when and what to use?
-
22
votes3
answers1335
viewsWhat is the advantage of dependency injection in relation to an object instance?
I’ve been reading and rereading What is addiction injection? but in the end I could not perceive an advantage of the injection of dependence in relation to an object instance. What is the advantage…
-
21
votes1
answer631
viewsWhat is the difference between DI, Factories and locators?
Already I asked about addiction injection. It is widely used. In my opinion it is even abused. But I saw that in her place you can use Factories or locators. What would they be, what are the…
pattern-design software-engineering dependency-injectionasked 7 years, 7 months ago Maniero 444,682 -
10
votes1
answer1562
viewsUnit Of Work + Ioc + Idisposable
I’m putting together a project that I use Uow to facilitate the issue of transactions. In some scenarios, I use several repositories, persisting the data in memory to save at once in the BD using a…
-
9
votes1
answer5156
viewsWhat is the difference between @Inject and @EJB when injecting an EJB?
I have an EJB that relies on another EJB, so I’m going to use dependency injection to satisfy that dependency. My question is: what is the difference, advantage or disadvantage between @Inject and…
-
8
votes3
answers4468
viewsBest(s) way(s) to use Dependency injection in Laravel
What(s) is the (s) best(s) way(s) to use Dependency injection in the Expandable? The one I was using was this: public function __construct(Cliente $clientes, Telefone $telefones){ $this->clientes…
-
7
votes1
answer580
viewsDependency registration responsibility (Ioc, DI, n-layer architecture)
I’m starting a WPF (.NET/C#) project using an n-layer (Domain Driven Design) architecture, and to implement Control Inversion and Dependency Injection (Ioc/DI), I’m trying to use Microsoft’s Unity…
-
7
votes1
answer239
viewsProject Dependency Injection . Net Web API 2
I am involved in a project that is developing an application .Net Web API 2 Fw 4.51 (with a view to future migration to .Net Core, what is an 'aggravating'), Fluent NHibernate e PostgreSQL, and we…
.net asp.net-web-api dependency-injection asp.net-core iocasked 8 years, 2 months ago Carlos Felippe Vernizze 71 -
6
votes1
answer564
viewsHow does a Dependency Injection Framework work? Are they useful in Ruby?
Java and C# people keep quoting frameworks Injection of Dependencies. I know the pattern of Dependency Injection projects, but never worked with such frameworks. In fact, I have no idea how they…
-
6
votes2
answers156
viewsWhat are the principles of the dependency injection mechanism?
It has been a while since I try to understand the injection mechanism of dependency and its main essence, however, it does not enter my mind, maybe it is by not understanding the fundamentals and…
software-engineering dependency-injection language-independentasked 3 years, 8 months ago gato 22,329 -
5
votes1
answer347
viewsWhat is CDI technology?
I am developing a web application and a university colleague who is a few periods beyond what I am currently studying said that using CDI would have a better performance, however, until now had not…
-
5
votes1
answer1032
viewsDependency Injection in . NET Core
I am migrating a Webapi project with . NET Framework 4.6 to . NET Core. In this my project I use Unity to do Dependency Injection: var container = new UnityContainer(); DependencyResolver = new…
-
4
votes1
answer554
viewsInjection of Beans Spring into JAX-WS / Tomcat 7 (@Webservices) - Does not work, returns Nullpointerexception (NPE)
I’d like to inject (@Autowired or @Resource) Beans created by Spring (3.x or 4.x) in a class that implements a JAX-WS interface (reference implementation). I tested on Tomcat 6 and it works, but on…
-
4
votes2
answers252
viewsScope equivalent to @Stateless on CDI
I’m migrating the notes EJB from my application to CDI and I have some doubts: What is the equivalent scope @Stateless of the EJB at the CDI? The @ResquestScoped would act in an equivalent manner? I…
-
4
votes1
answer566
viewsDemoiselle 2.4.0: Error running test with Junit
I have a project built from the archetype of Demoiselle for Maven. The generated application is the one that exemplifies the Demoiselle, containing a register of bookmarks. The programmer who…
-
4
votes3
answers655
viewsController Base Dependency Injection
Well I’m learning to work with the dependency injection now and I’d like to apply it to my project. But I came across the following difficulty, I have a controller base where it is inherited by…
-
4
votes1
answer147
viewsInjection of dependencies into functions and not classes. Is it "wrong"?
It is not new that the concept of dependency injection is almost directly related to classes. Tell me "dependency injection" and I can imagine the following: // services/UserService.ts export…
typescript pattern-design encoding-style dependency-injection iocasked 5 years, 4 months ago Luiz Felipe 32,886 -
4
votes3
answers290
viewsHow to make compatible objects coming from two different classes, derived from the same interface?
I have an interface (I’ll call it ICliente) which is used as a contract between an application and a DLL. public interface ICliente { int Id {get; set;} string Nome {get; set;} ... } This interface…
-
3
votes2
answers472
views@Autowired bean in Filter
I’m trying to inject a bean in a filter but without success, the same always remains null causing error. Below follows the code of bean: @Named @Scope("session") public class LoginBean { Of filter:…
-
3
votes2
answers870
viewsHow best to reuse code between modules
I am developing a tool using Angularjs, but I am constantly picking it up, I need to reuse code from different modules and files, but it is not working properly. With pure javascript, it’s easy to…
javascript angularjs oop dependency-injection angular-moduleasked 9 years, 1 month ago Victor Siqueira 638 -
3
votes1
answer167
viewsMVC# - Mongodb 2.0 dependency injection
I’m starting a project using MVC 4 with Driver 2.0 of MongoDB. I’m used to using Ninject with EF6 and would like to know if there is such a thing as MongoDBor some example architecture standard for…
c# pattern-design mongodb dependency-injection mongodb-csharpasked 8 years, 10 months ago Jhonathan 1,399 -
3
votes2
answers398
viewsCreate modules using Unity (Ioc)
In an application using a multi-tier (n-layer) architecture, we have the infrastructure layer where we use an Ioc container to record the required dependencies. In a prototype I’m working on, I’m…
-
3
votes1
answer256
viewsDoubts about implementation of Lazy Load and Dependency Injection
The scenario is simple, it has a Personal Physical class that has linked to it a list of Contacts (instances of physical persons), Telephones (instances of an entity Telephone) and a list of…
c# asp.net pattern-design dependency-injection lazy-loadingasked 9 years, 6 months ago Intruso 1,625 -
3
votes1
answer502
viewsNinject does not load dependencies. Asp.NET MVC C#
I’m using Ninjectwebcommom to work with Inject. I installed the package via Nuget and automatically it creates a class named "Ninjectwebcommon" in the App_start folder, as the documentation itself…
-
3
votes1
answer148
viewsController dependency injection with Ajax
Good afternoon, I am using ASP.NET MVC 5 with Windsor and when an Ajax request calls a method in the controller, the error informing that the controller has unsatisfied dependencies. How do I work…
c# asp.net-mvc ajax dependency-injection castle-windsorasked 9 years, 2 months ago Alan Almeida 633 -
3
votes1
answer475
viewsUsing dependency injection outside a controller with ninject
I have following code: public class ContaController : ApiController { private readonly IAppServiceUsuario _app; public ContaController(IAppServiceUsuario _app) { this._app = _app; } } how to inject…
-
3
votes2
answers150
viewsHow do you register all validation classes with Dryioc?
How can I log all my validation classes using Dryioc dynamically ? I’m trying this way down; using DryIoc; using FluentValidation; using System; using System.Linq; using System.Reflection; namespace…
-
3
votes1
answer565
viewsInjection of dependency Generics<T>
Good morning friends. I hit a rough patch and I’m not getting past it. I have 2 projects, a webapi and a standard class, both in dot net core. In my standard design, I am working with Repository to…
mongodb generic dependency-injection .net-core asp.net-coreasked 7 years, 1 month ago Guilherme Dietrich 31 -
3
votes2
answers262
viewsHow to use Simpleinjector in a multi-layer project?
Imagine the classic architecture: Consoleapplication (Frontend) --> Business Layer (BLL) --> Data Access Layer (DAL) That is, Frontend references BLL that references DAL. See that Frontend…
c# software-architecture dependency-injection ioc simple-injectorasked 6 years, 10 months ago Ewerton 194 -
3
votes1
answer69
viewsInjection of Dependencies Layers Application / Domain / Repository
In an application using the concepts of DDD I am in doubt about who could inject (dependencies) in a certain class, if there is any standard for such. This is the following between the Application,…
asp.net software-architecture ddd dependency-injection solidasked 6 years, 6 months ago LeoFelipe 1,455 -
2
votes1
answer94
viewsNullpointerexception with CDI and JAX-RS
I’m studying JAX-RS and created a simple project with the following class: Webservice @Path("generic") public class GenericResource { @Inject private MeuServico servico; @GET @Produces("text/plain")…
-
2
votes1
answer649
viewsSpring Framework in modular design by Apache Maven
I created a modular web project using Apache Maven with the following structure: proj-build |--- proj-utils |--- proj-persistence |--- proj-services |--- proj-web `--- proj-ear Description…
-
2
votes1
answer710
viewsDoubt with Spring dependency injection (injected object returning null)
good afternoon to all. Guys, I have a little problem that I should probably be missing or forgetting the order of something. My case is that I have one two controllers. One of them I call…
-
2
votes2
answers1104
viewsBest Way to Perform Dependency Injection on Angular JS
I am working on a very large system where I am creating several modules and needed to guide them in a coherent way. Currently I am centralizing the injection of dependency in a single module, what I…
-
2
votes1
answer362
viewsHow Does Life Cycle Dependency Injection Work?
How the 3 life cycles of a dependency injection works such as Singleton, Transient and Scope ?
-
2
votes2
answers906
viewsLogoff with database registration and cookie deletion behind Session_end() in Global.asax
I need help with a project I’ve been racking my brain about for two days. I’m using Microsoft C# MVC5 technology and framework 4.5, I also use Entity Framework 6 with Repository Pattern, Unit of…
-
2
votes0
answers257
viewsHow to write the Junit test with Spring Autowire?
I am currently setting up a Dynamic Web project to run unit tests, but this project is using dependency injections by Spring Frameworks, it is important to mention that the version of spring that…
-
2
votes1
answer66
viewsHow to register dependencies with Windsor that are in different layers of the application?
How to register dependencies with Windsor that are in different layers of the application? I don’t want to keep referencing all layers of the application in the presentation layer as most do around.…
-
2
votes1
answer564
viewsAutowired spring boot in Jframe
In the development of a Spring Boot application for Desktop, it is possible to inject a @Repository in a class JFrame? If yes how? Some alternative? Code examples: @Repository public interface…
-
2
votes1
answer121
viewsIoc with Web Service
I need to create a WS with Ioc. I created a new Web project with Web API dependencies ; I added a Web Service (asmx); I installed the Simpleinjector; The code went like this : [WebService(Namespace…
-
2
votes0
answers82
viewsDoes Xamarin Forms dependency service not work with Generics?
I need to generate an instance of a generic class with Xamarim Forms using dependcy service (or a DI framework). With the code below I can generate an instance without problems: Interface namespace…
-
2
votes1
answer48
viewsAndroid Dagger 2.10 or higher - void inject X @Bindsinstance?
I have a big question about the correct use of Dagger 2.10 or higher for android implementing according to the specifications of the Dagger documentation for Android. Example code: @Singleton…
-
2
votes1
answer253
viewsWhen should a utility class become an injectable dependency?
I often write small utility classes to solve some minor problem in my code. For example (I will use Spring for DI): @Service class PessoaService { public PessoaResponse converter(Pessoa pessoa, Long…
-
2
votes3
answers271
viewsI can’t do addiction injection
I’m working with ASP.NET CORE 2 and is a layered application. This is my ConfigureServices in the Startup.cs public void ConfigureServices(IServiceCollection services) {…
-
2
votes1
answer663
viewsCheck if the driver has a public constructor without parameters
Someone helps me, I am creating a project and in the dependency injection part I am having the following error when I make a Postman request in my Api: An error occurred when trying to create a…
-
2
votes1
answer113
viewsDependency Injection and Generic Repository Windows Forms C#
I have a windows Forms application where I am trying to use dependency injection for some services, for this I did the following configuration initially in Program.Cs I register the services: static…
-
2
votes0
answers69
viewsAre there advantages or disadvantages between using closures or classes to achieve Javascript dependency injection?
Let’s say I have a function that depends on a logger to work. To follow the "good practice" and achieve a certain level of decoupling, I decide to make use of dependency injection so that this…
javascript classes software-architecture dependency-injection closuresasked 3 years, 9 months ago Luiz Felipe 32,886 -
2
votes0
answers27
viewsContext User does not return username Asp Net Core 3.1 C#
I’m trying to get the username logged in by the User context inside a controller. I’m using Identity to manage login and JWT to authenticate requests in my controller. I can get the values:…
-
1
votes3
answers364
viewsHow to get the class name where a bean will be injected?
I am configuring two Beans in the file beans.xml to inject Loggers into my classes. <bean id="loggerFactory" class="company.LoggerFactory" /> <bean id="logger"…