inversion-of-control Questions

3

Some times interfaces are annotated with @Component annotation. Then my obvious reasoning was that classes that implement such interface will be treated as components as well. But if I am right tha...

8

Can someone guide me to some basic tutorials on inversion of control (IoC)? (preferably .net/c#). I need some hands on code to wrap my head around it :)
Luteous asked 26/2, 2009 at 19:47

40

Solved

Inversion of Control (IoC) can be quite confusing when it is first encountered. What is it? Which problem does it solve? When is it appropriate to use and when not?

7

Solved

With regular ASP.NET MVC pages, the repository is passed in to the constructor of the control. Then the tests can instantiate the controller passing in a mock repository. How can I do this with we...

30

Can @Component, @Repository, and @Service annotations be used interchangeably in Spring or do they provide any particular functionality besides acting as a notation device? In other words, if I hav...
Uncanny asked 26/7, 2011 at 9:10

4

Solved

Why is Spring @Value Annotation not working in the constructor? I have this Email class that is reading some email related configuration. In the constructor, if I put a break-point the values are ...

2

Solved

This is my dad class public class Dad { public string Name { get;set; } public Dad(string name) { Name = name; } } This is my test method public void TestDad() { UnityContainer Dad...

6

Recently I asked a question about software architecture Should service call another service or repository directly? After that answer, I reorganized and refactored my application. In a simple way...

3

I have an MVC project that will accept data via the HTTP 'Post' verb. I'm keen to follow best practice and wanted to ask a quick question around how best to set up my models. Generally when working...
Centiliter asked 26/5, 2015 at 12:14

2

Solved

Right now I'm trying to teach myself the Dependency Injection pattern with the IOC-container from Autofac. I've come up with a very simple example, which is presented below. Although the example is...

4

Solved

Is it possible in Spring to autowire only specific arguments of a constructor? I defined: <bean class="MyClass"> <constructor-arg name="name" value="object name" /> </bean> W...
Semite asked 5/7, 2012 at 14:16

23

Solved

I am currently getting this error: System.Data.SqlClient.SqlException: New transaction is not allowed because there are other threads running in the session. while running this code: public c...
Delagarza asked 21/1, 2010 at 22:37

2

Inversion of control is a value-proof technique which is used to modularize a system and decouple the components from each other. Low coupling is always an advantage: it simplifies automatic testi...

3

I have gotten stuck while trying to get my asmx web service to use dependency injection and using an IoC to do it. I want my webservice to be able to use my internal business layer services. The we...
Management asked 21/10, 2011 at 6:35

7

Solved

On an ASP.NET MVC 5 application I have the following StructureMap configuration: cfg.For(typeof(IRequestHandler<,>)).DecorateAllWith(typeof(MediatorPipeline<,>)); Does anyone know ho...
Sienkiewicz asked 12/4, 2016 at 11:54

22

Solved

I currently creating some experimental projects with nodejs. I have programmed a lot Java EE web applications with Spring and appreciated the ease of dependency injection there. Now I am curious: ...
Lottery asked 12/2, 2012 at 17:19

10

Solved

I find that my constructors are starting to look like this: public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... ) with ever increasing parameter list. Since "Container" is my dep...

2

I am migrating a large codebase from Ninject to Autofac and am struggling on one of the bindings that I believe is causing an activation error based on some of my debugging. Ninject: Bind<ISecur...
Transfinite asked 28/3, 2018 at 13:56

6

Taking configuration as an example, the Nest.js documentation advocates registering Config Modules and injecting them into other modules in a dependency injection way. The benefits are obvious, and...
Biostatics asked 20/2, 2021 at 12:4

4

I am debugging my Java Spring service and I get an @Autowired variable as null, when it shouldn't be. Since I have declared the service's class as @Service, I want to double-check that my bean was...
Macon asked 11/2, 2016 at 20:50

4

Solved

I am trying to implement the Domain Event pattern in C# using Simple Injector. I have simplified my code to be in one file that can be ran as a console app and have excluded the Simple Injector co...
Interactive asked 3/6, 2015 at 16:10

3

Solved

Is creating objects by hand, i.e. using new operator instead of registering Spring bean and using dependency injection considered bad practice? I mean, does Spring IoC container have to know about ...

2

Solved

I was reading Wikipedia's definition of Dependency inversion principle, and it uses two terms High-level modules and low-level modules, which I wasn't able to figure out. What are they and what d...

8

Using a IOC container will decrease the speed of your application because most of them uses reflection under the hood. They also can make your code more difficult to understand(?). On the bright si...
Improvement asked 5/2, 2009 at 7:52

5

Solved

My question is simple. Which approach is more efficient? As I see, the DI in the method2 is more recent. But I wanted to ask you which one should I use? method 1: @Autowired private CustomerReposit...
Tiffanitiffanie asked 1/4, 2022 at 19:49

© 2022 - 2025 — McMap. All rights reserved.