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

4
votes
0answers
41 views
3
votes
0answers
33 views

Properly using parameterized Factory.Create() method using DI

My factory is using method injection because I thought this was the best way to make it so far. Besides, I doubt it is a good thing after having to call on its ...
0
votes
0answers
10 views

Shall the Presenter depends on the View, or the contrary, in MVP? [migrated]

So far, I have used the MVP architecture pattern a few times. Every now and then, I wonder whether my Presenter shall depends on my ...
1
vote
1answer
39 views

RouteContext as constructor parameter or method parameter in ASP.NET vNext

I have this simple class where I load an object from the database and store it into the RouteContext.DataTokens because I need to access it through out the request. ...
4
votes
2answers
66 views

Is it a good practice to use only one database instance?

I want to ask whether is good practice to have single instance of database connection or declare new every times when we needed? I have this two designs shown in below: This is database class: ...
1
vote
3answers
76 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 ...
7
votes
2answers
79 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 ...
10
votes
2answers
101 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
244 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
197 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 ...
0
votes
1answer
68 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
175 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
78 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
191 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
43 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
161 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
88 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 ...
2
votes
1answer
85 views

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
305 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
197 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
130 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
215 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 ...
8
votes
3answers
191 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
238 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
54 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
116 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
169 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
98 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
87 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
184 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
120 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
501 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
182 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
566 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
596 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
299 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
964 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
333 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: ...
3
votes
1answer
372 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
207 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
808 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
190 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
468 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
78 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
266 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
94 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 ...