Design pattern to reduce coupling between components, by dynamically injecting into a software component dependencies that it needs to function.

learn more… | top users | synonyms

1
vote
3answers
59 views

Dependency injection/dependency injection containers in MVC web app

I just learned about dependency injection/dependency injection containers, so this is my test using DI/DIC in my MVC app. Controller ...
5
votes
1answer
45 views

Down the rabbit hole with MVP

Following-up on this post where I implemented a Repository Pattern in vba to abstract ADODB and enable testing my Excel app without hitting a database backend; curious about how far vba would let me ...
9
votes
2answers
77 views

YARPI: Yet Another Repository Pattern Implementation

Following-up on this post, I wanted to be able to put a copy of that Excel workbook on a USB key and take it home to keep working on the code a bit (there's more than just one or two tables to ...
10
votes
2answers
162 views

Do I need ninject when implementing DAL with generic repository and unit of work?

I am implementing generic repository and unit of work for the first time. I would be glad if someone can correct me if I am doing something wrong here. This is how I communicate with my DAL from ...
4
votes
1answer
84 views

Autofac DI container in console app

Just used DI containers in MVC projects, via constructor injection, and I'd need to now inject a service into a console app. I'm using Autofac so I followed what I found here. The code would be ...
1
vote
1answer
47 views

Unity DI Composition Root vs XML [closed]

I'm having trouble figuring out the best approach with DI. After doing more research, Mark Seeman recommends using the Composition Root approach. In my example, I am using XML configuration to design ...
2
votes
1answer
106 views

Laravel - lots of dependency injection

I have the following UserServiceProvider and I'm wondering whether so much dependency injection is overkill: ...
2
votes
1answer
70 views

Calling a copy constructor in Presenter to prepare a list of Models

I'm new to MVP. In a presenter I have following code. Here what am I trying is to create a list of Model objects (in this case ...
6
votes
2answers
161 views

Will this Circuit Breaker catch fire?

I was going to post this code as an answer to a recent question, but I wrote this code a little while ago (like, a year ago; if I recall correctly I wrote this after reading this article) and I'd like ...
3
votes
0answers
54 views

Using a UserPermissionService by all Presenters in the Application to control the access to commands

I'm handling user permission in a MVP Winforms application as follows. Here I'll give a full detail of my code as it will be helpful when answering to this question. My user model has a list called ...
1
vote
1answer
38 views

Inheritance or DI in Presenter classes in MVP [closed]

In MVP pattern we can use DI when our presenter classes need services as follows: ...
7
votes
3answers
120 views

VB6/VBA Declaration (Dim) Syntax Parser

As part of a project I'm working on, I've implemented a class that encapsulates the syntax for a vb6/vba Dim statement. Given a line of code, the ...
3
votes
0answers
55 views

Building a console application using a DI service container

I am working on a project that will allow developers to create a console application using a dependency injection service container. Both the console and container are Symfony components with some ...
1
vote
0answers
58 views

Problem in designing a MVP win forms application

In a module of a win forms application I have a hierarchy of classes like BaseRecovery, LoanRecovery and ...
1
vote
1answer
159 views

Async Log4net logging handler - High CPU usage on async call

I've got a LoggingMessageHandler that incoming requests on my WebApi application filter through. ...
5
votes
2answers
182 views

Gift aid calculator task

I have recently taken a small technical test in C# and the following were expected: All stories to be completed with an appropriate level of testing. No actual database implementation is required, ...
1
vote
2answers
108 views

MVP Pattern used in a payroll solution

I'm using MVP pattern for a payroll system as my final year project. There are about 16 entity classes (like employee, client, ...
3
votes
3answers
131 views

Using Poor Man's DI to inject helper class dependencies

I had a rather large method in one public class that I refactored into 2 helper classes. The thing is though, that those 2 helper classes have dependencies. I refactored them into helper classes so I ...
7
votes
3answers
169 views

Refactoring method to make it unit testing friendly

I have a completed application which I'm trying to write unit tests for (Yeah I know, talk about bad practices) I have the following class here ...
2
votes
0answers
180 views

Generic Repository, UnitOfWork and IOC container

I am stuck to define a generic repository with AutoFac IOC container. I am keeping thing very simple and only showing relevent information. I have a BaseEntity ...
1
vote
0answers
48 views

Split large import task into smaller subtasks

I have a large import task that runs as a cronjob and I want to split that task in smaller subtasks. Each subtask should be handled by an own class. At the cronjob entry point I prepare the ...
3
votes
1answer
111 views

Going from Spaghetti PHP OOP to SOLID OOP

I am beyond stuck in a half way point between PHP structural and OOP, but I can never achieve proper SOLID patterns despite reading DI, IOC, and reading about the interfaces. Rather than to read ...
10
votes
1answer
157 views

Should a Factory ever be generated per request?

I'm working with AutoFac to do some DI. I think I've got a decent grip on things, but just ran into a question I had with my code and thought I'd check: ...
3
votes
2answers
76 views

Dependency on overridden method

In my code I have a base type which is OnlinePaymentTransaction: ...
5
votes
1answer
92 views

Improving XNA's default project template

I hope this isn't getting annoying, but I've asked a lot of questions about improving my game lately: How can I improve my game project design? Using the observer pattern with collision detection Is ...
2
votes
2answers
82 views

How to declutter dependencies?

I'm running into a problem with my code in a ASP.NET MVC application. Maybe it's not a problem and I'm just being paranoid, but it seems like a problem to me (might be because I've just read the book ...
11
votes
2answers
171 views

Setting up keyboard bindings using JSON (no reflection!)

I got a lot of good feedback on my other question. So I will take another swing at it, post my revisions, and hopefully get some more. First, the configuration hasn't changed. Here's the JSON file: ...
5
votes
1answer
55 views

Setting up keyboard bindings using JSON and reflection

My game uses configuration files in JSON format. One of them is used for setting up control bindings, and it looks like this: ...
7
votes
1answer
114 views

Is this a sensible way of using an IoC container?

I have a Factory class for a queuing system I'm playing around with. Consuming classes only care that they get a particular interface (Job) as a result of calling the factory's load method. Some ...
6
votes
2answers
354 views

Spring password validator library

I recently got rejected at a job interview for submitting this: https://bitbucket.org/gnerr/password-validator The interviewer asked for a password validation library that was configurable via ...
2
votes
3answers
161 views

Controller with too many dependencies?

The main impetus for this review is to determine if my ASP.NET Web API controller has too many dependencies. I'm of the opinion that 3-4 is okay, but 6 seems like too many. I have many controllers ...
0
votes
1answer
444 views

Understanding Dependency Injection and Inversion of Control

I have recently been looking into the concepts/patterns behind dependency injection, inversion of control, and registries/service locators. I have searched about the internet on the subjects and have ...
12
votes
1answer
588 views

How can I solve my constructor injection code architecture?

The current code solves the issue I had when trying to use property injection. Problem: Every module must use constructor injection because of a circular reference that occurs when not using ...
10
votes
2answers
293 views

Rock-Paper-Scissors-Lizard-Spock Challenge, take 2

This post is following-up on Rock-Paper-Scissors-Lizard-Spock Challenge I had a gut feeling that I was somehow abusing IComparable<T>, @svick's answer ...
23
votes
4answers
890 views

Rock-Paper-Scissors-Lizard-Spock Challenge

"Scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes scissors, scissors decapitate lizard, lizard eats paper, paper ...
8
votes
3answers
328 views

Why would I want to always have to explicitly call a “base” method if I just want to use base functionality?

I recently worked with an architect who structured his base class like this: ...
2
votes
1answer
325 views

Looking for advice - Dependency Injection over Service Locator in Mef

I'm wondering what people think about Dependency Injection vs Service Locator patterns. Specifically I'm using Prism with MEF. I'm also using the MVVM pattern. So I have a service which I export. I ...
6
votes
1answer
206 views

Having trouble with KISSing

There's a bit of a weird piece in my API that I'm not too happy about, but I can't seem to see any other way of going about. It involves a IFunctionalityFactory ...
3
votes
2answers
664 views

Enabling discard pending changes on DbContext

This code review request is tightly coupled with this SO question, this is the solution I implemented to solve the problem being asked about there. All my ViewModels get constructor-injected with a ...
5
votes
2answers
184 views

Object can throw exception on construction, but I don't want it to stop everything

I have a factory that loads configuration from an xml file, and uses the configuration to be able to create objects of an appropriate type with appropriate settings. My application does a number of ...
3
votes
1answer
410 views

Multiple Ajax Requests per MVC 4 View

I'm using the repository pattern with a context and ninject as the IOC. I have a service which handles getting and setting page properties in the database. ...
3
votes
1answer
75 views

Guice custom behavior for testing, how is this solution?

I have a Java/Swing/Guice application that uses multiple frames. When the application runs normally, I just want some of these frames to hide (and the "master" frame can unhide them). When testing ...
1
vote
3answers
259 views

Constructor Injection, new dependency and its impact on code

This is my interface, all of my transport concrete classes will be implementing this interface. interface ITransport { void Travel() } These are my existing ...
1
vote
2answers
92 views

Unit Test to verify number of times lazy initialization logic is executed for a data member

I'll write a small simulation of my actual class first to request insights on unit testing one of the behaviors of this class. Here is my class A: ...
3
votes
1answer
5k views

Select list items in ViewModel fetched using a Repository

Doing database access in ViewModel is generally considered a bad practice. However, when you have a <select> in your view, you need to populate it using the ...
2
votes
1answer
55 views

Review of template parsing function

I am using preg_replace_callback(), and I am concerned that I might have some sort of security risk. I am hoping to get a review of the below ...
2
votes
1answer
530 views
7
votes
2answers
250 views

Send message with SignalR to client(s) from injected (IoC) method

I am new with SignalR and still a newbie with IoC Container SimpleInjector and I am ...
5
votes
2answers
2k views

Spring autowiring in managed beans with support for serialization - is this safe?

Im trying to solve two problems I see with JSF2 and Spring. First @Autowired in @ManagedBean does not work Nor does ...
10
votes
1answer
2k views

Is this the right way to inject AutoMapper profiles

I'd like to know if I'm doing profile configuration in the wrong place or in the wrong way. I'm following the Onion Architecture. So that restricts the direction of my dependencies towards the ...