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

7
votes
3answers
132 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 ...
1
vote
0answers
61 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
35 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
80 views

How to go 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 ...
9
votes
1answer
98 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
74 views

Dependency on overridden method

In my code I have a base type which is OnlinePaymentTransaction: ...
4
votes
1answer
67 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
73 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 ...
10
votes
2answers
157 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
50 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: ...
5
votes
0answers
59 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
161 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
113 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
213 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 ...
11
votes
1answer
553 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
278 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 ...
15
votes
4answers
705 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
308 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
223 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
199 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 ...
2
votes
1answer
302 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
173 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
310 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
64 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
241 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
77 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
3k 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
52 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
324 views
2
votes
0answers
153 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 ...
3
votes
2answers
1k 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 ...
8
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 ...
6
votes
1answer
263 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 ...
1
vote
0answers
69 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
203 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
135 views
2
votes
1answer
4k 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 ...
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
361 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
397 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
199 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
346 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
567 views

Storage class, dependency injection and singletons

In re-writing my PHP framework vervPHP, I've created the following class: ...
4
votes
2answers
818 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 ...
5
votes
2answers
522 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, ...