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
24 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
101 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
78 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
123 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 ...
6
votes
0answers
190 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 ...
9
votes
2answers
219 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 confirmed that. As @dreza was posting his ...
14
votes
4answers
610 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
294 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: public abstract class Base<T> { public abstract T Get(int id); internal T InternalGet(int id, ...
2
votes
1answer
162 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
195 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 abstract factory: public interface ...
2
votes
1answer
188 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
160 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
223 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. public class MyContext : DbContext { ...
2
votes
0answers
47 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
230 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 implementation class: class Horse : ...
1
vote
2answers
71 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: public class A { private final String a; ...
3
votes
1answer
2k 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 ViewBag or the ViewModel (I prefer ...
2
votes
1answer
50 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 substitute() function. The purpose of the function is to ...
1
vote
1answer
215 views

Are there side-effects to having a generic Ninject factory?

Consider this class: using Ninject; using Ninject.Syntax; using Ninject.Parameters; namespace MyApp.Dependencies.Factories { public abstract class FactoryBase<T> where T : class { ...
2
votes
0answers
136 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 wondering if there are any side effects and/or if I'm save with my chosen approach. In my web app I have a SetupHub ...
1
vote
0answers
873 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 @ViewScoped with @Controller @ManagedProperty is not type safe and requires ...
5
votes
0answers
1k 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 ...
6
votes
1answer
258 views

Doubts about the quality of an API designed for use with minimal effort

This is going to be long, and I do hope it is going to make some kind of sense; I apologize if it doesn't. I'll try to provide exactly the amount of context that is necessary to understand the ...
0
votes
0answers
64 views

Data Access Objects and Entity Relationships

What is the proper way to structure DTO's for my tables? Three of my tables are Documents which contains Pages and Fontstyles. I am creating an EditDocument view in which I will edit these (and more) ...
2
votes
1answer
187 views

First steps with PHP OOP

I am learning OOP using PHP5 and I wrote two simple classes for receive data of database using dependency injection pattern and render a grid with Twig. Please, if is possible, take a look and give ...
0
votes
1answer
123 views

how should you mock / unit test this method / class

I have the below code: public interface IRepositoryService { /// <summary> /// This will add conditions like Published = true, Deleted = false and PublisehdDate smaller than NOW /// ...
2
votes
1answer
3k views

Entity Framework & Unit Of Work Design issue with Repository & DI, Please Help

I am facing a problem to save data using UnitOfWork. I mean I am unable to save data using UnitOFWork.Commit() from Controller class. My Implementation check bellow. IUnitOfWork public interface ...
4
votes
1answer
1k views

Inject dependency into PostSharp aspect

I have designed couple of aspects using PostSharp for different projects, but there is a design flaw in many of them: dependency management. This is a question about injection of dependencies into ...
2
votes
2answers
337 views

Illustrating DI and IoC concepts : Simple code requesting review

I have written a little bit of code which illustrates DI(dependency injection) and IoC(Inversion of control) container. The point of this exercise is to illustrate the two methods by which you can ...
1
vote
2answers
343 views

Nesting multiple objects vs referencing them

After experimenting with different design approaches for the past two years, I've created a library for managing and processing dynamic content to be displayed on a single HTML view. This library is ...
3
votes
1answer
185 views

PHP: Dependency Injector Container

I've been working on my own PHP framework for my projects. I just finished coding my DI container. There is always room for improvement. Any input be it good or bad on my code would be appreciated. ...
6
votes
1answer
2k views

Can someone review my AutoFac, NHibernate & ASP.NET Web API integration?

I've recently been learning (and struggling with) integrating AutoFac, NHibernate & ASP.NET Web API. I have found several tutorials with code that did not work as anticipated but managed to ...
5
votes
1answer
310 views

Dependency Injection Provider/Container

I've been working on a class to handle dependency injection across some code akin to a micro-framework. This is also my first real dive into any sort of wrapper for dependency injection. I decided to ...
5
votes
3answers
518 views

Storage class, dependency injection and singletons

In re-writing my PHP framework vervPHP, I've created the following class: class storage { private static $instance; public $db = null; // Holds a database connection object public $user = ...
4
votes
2answers
734 views

Working with dependency injection and factories

Thanks in advance for any insight. All used classes are at the top, and everything starts at the comment: // where the magic happens In particular, I am looking for feedback on my attempt at using ...
5
votes
2answers
505 views

DI Container: You're doing it wrong?

I'm working on a framework (partly out of frustration with Zend, and partially as a learning exercise to improve my coding). I've constructed a fairly solid library of classes for data validation, ...