Questions tagged [dependency-injection]

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

49 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8
votes
0answers
120 views

Geode Contents Predictor StardewValley Mod

The goal I really enjoy the game Stardew Valley. One of the things that the game has are geodes. Much like real-world geodes, these geodes can be cracked open, and you can find some fun things inside....
7
votes
0answers
1k views

Flask view dependency injection

so, first of all, I've been into trying to have a simple dependency container as possible in python and with your help managed to get conceive https://github.com/dareenzo/tinydic, many thanks. Now, I ...
5
votes
0answers
75 views

Using ClientFactory-pattern with Dependency Injection

I initially posted this on Stackoverflow but was recommended to try here instead. I'm looking for feedback on why the implementation of my ClientFactory is probably bad, from a Dependency ...
5
votes
0answers
242 views

Auto register Func<T> for .net core dependecy injection

The default .net core dependency injection doesn't support building Func<> for injection automatically, see question. I wrote an extension method to go find all the Func in register types ...
4
votes
0answers
66 views

Production planner

I have a class that creates an object, PlannedYear, and then passes that object into several other classes to manipulate it. The ultimate goal of the class is to ...
4
votes
0answers
80 views

One interface for multiple CRUD resources

I asked about an abstraction layer for accessing files (link) a couple of days ago (I decided to not call it a follow-up anymore as there are too many changes). I tried to incorporate many of the ...
4
votes
0answers
3k views

Using IServiceScopeFactory without implementing the Service Locator Pattern

I want to use IServiceScopeFactory in a way, which is not the Service Locator anti-pattern. Therefore I thought about making a generic one, which supports ...
4
votes
0answers
3k views

Logging in ASP.Net MVC project

I want to implement a Logger and use Serilog as Provider. My Project is ASP.NET MVC Framework (not core). Initially I tried to replicate ASP.Net Core Logging framework. I created a ...
4
votes
0answers
154 views

“Ymbirtt vs The Gilded Rose” Kata

The Gilded Rose Kata is a refactoring challenge, in which some frankly disgusting code is thrown at the developer, and they're told to make a small change to it. For reference, the (truncated) ...
3
votes
0answers
59 views

ASP .NET Core DI: Dependency on single implementation of multiple registrations of service type

Problem I have a DI scenario where I have multiple classes that implement a common interface (IModelService). I'm using a generic framework class (...
3
votes
0answers
42 views

HTTP Delete,Put,Get,Post REQUEST java-ee RESTful services JPA CDI EJB

I am creating introduction app to java ee and APIs of java ee and i want know if my code is ok (like its working but if it could be done better) and what should i avoid in future ...
3
votes
0answers
56 views

Using functional interface arguments in methods of services injected via Spring

Here is the working code for my Spring service: ...
3
votes
0answers
63 views

Override prototype inside of constructor of ES6 class for dependency injection

We implemented a small dependency injection mechanism which we use in our project. Now after 2 years of developing our project we need our classes to know who instantiated them via dependency ...
3
votes
0answers
379 views

Generic repository accessor in a unit of work

I'm giving the repository + UoW patterns my first shot on the server side, so bear with me. Also, it's worth mentioning that I haven't used an IoC container on the server side before either, so I'll ...
3
votes
0answers
696 views

Tiny calculator using dependency injection and inversion of control

I've started to learn very interesting concept of DI, IoC and related stuff. I have decided to learn it using simple application, very tiny calculator (only basic functions: add, subtract, multiply &...
3
votes
0answers
611 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
0answers
33 views

Swift MVVM: Repositories - loading entities and dependency injection

I create a lexikon and a navigation for ZOO. I use MVVM architecture supported by ReactiveSwift. I have a few questions about my practises and whether I could write my repositories better and more ...
2
votes
0answers
196 views

Ninject binding for Dbcontext

I have an asp.net web API and I am using EF6 to connect to a third party rest API which sells online game codes. We made a deal with the company so clients have to call my rest API in order to get the ...
2
votes
0answers
95 views

Create an isolated dependency scope with “overrides” in Asp.Net Core

Some of the classes in my multi-tenant Asp.Net Core application depend on database repositories which in turn depend on a delegate called GetCurrentTenantKey. In ...
2
votes
0answers
151 views

GUI to control a NZXT cooling and lighting system

I am working since a couple of weeks on my first Python application and I would love to have a review of the code I wrote so far. The app has the purpose of controlling the cooling and lighting of an ...
2
votes
0answers
57 views

Dependency Inversion in constructor

Currently I'm learning OOP and meanwhile I'm trying to keep the SOLID principles. Is it right to inject dependency (GenName - generate file name) on File ...
2
votes
0answers
247 views

Show mobile SoundCloud player in WebView

Demo for a SoundCloud player in WebView for specific song or artist stream as a workaround because SoundCloud is not accepting API key request anymore. SoundCloudWebView: ...
2
votes
0answers
94 views

Centralized static factory methods with dependency injection

I am trying to make a small e-commerce backend in php. I centralized all the static factory methods in a class called EntityFactory. The main reason for that was to ...
2
votes
0answers
112 views

Find a (nearly) optimal route among several locations that can be found by Google Maps

The README should give you all of the information you need for a comprehensive review, and if it doesn't then please say so. If you would like to contribute a review but do not have time or desire to ...
2
votes
0answers
161 views

Keep clean SimpleIoc initialization when reusing UserControl

Originally I had ChildUserControl inside ParentUserControl inside MainWindow with this view-...
2
votes
0answers
452 views

Factory (pattern) of Commands (pattern) with additional dependency injection (dependency inversion pattern)

What would you improve at the following code, except: The problems I'm already aware of, marked as TODO Line width of at most 120 characters (I've run flake8 over ...
2
votes
0answers
80 views

Supporting all closure options in WinForms MVC application

I have a WinForms MVC application that uses Ninject for it's Dependency Injection (DI) / IoC Container. I have build quite a nice framework that allows the main shell (which uses a Docking Container ...
2
votes
0answers
309 views

ASP.NET MVC with automatic testing (follow up)

This is a follow-up of this question regarding MVC application architecture fit for automatic testing. I have rewritten the DI code based on the answer provided there and also created some tests to ...
2
votes
0answers
99 views

Abstract DI Container Scopes

I'm in the process of refactoring one of my open source projects, branch here. The basic idea of the refactor is to allow for classes and all of its children in the graph to be scoped. I wrote a blog ...
1
vote
0answers
46 views

Tightly coupled Basic Authentication Filter

I have an asp.net web api and I would like to use basic authentication. Is there any way to make this loosely coupled? I tried constructor DI but I couldn't figure it out how to pass Dbcontext into ...
1
vote
0answers
57 views

Dependency resolver in PHP

I wrote a simple Dependency Resolver in PHP that I'm hoping to get some input on. The main problem that gave me some trouble was when it had to resolve typed arguments ( like type hinting a ...
1
vote
0answers
201 views

Xamarin Forms with Ninject navigation service

I am new to Xamarin Forms and I have been searching online finding ways to set up navigation in a MVVM fashion. In particular I am designing around a concept I found here. However, I am using Ninject ...
1
vote
0answers
60 views

Dependency injection for a bus with a stop-request display application

I have been told that my implementation below doesn't need dependency injection, however Jeffrey Way uses DI in two similar examples in this tutorial: https://laracasts.com/lessons/tell-dont-ask and ...
1
vote
0answers
141 views

Generating Resource URLs in Multi-Layered Web API 2 Project

I am building a RESTful Api service in .NET. I have a requirement where I need to include resource URLs as part of JSON data returned from the endpoints of my API. The solution currently has the ...
1
vote
0answers
379 views

Simple Unity Integration

I've been working with web services recently, and I keep copying the same stuff to set up Unity for dependency injection, so I thought I'd extract the common stuff into a library. Here's the main ...
1
vote
0answers
2k views

Using IoC Container with Entity Framework Repository Pattern

I am using WPF with Entity Framework 6 (DB first), Caliburn.Micro, and MEF. I am trying to ...
1
vote
0answers
333 views

Refactoring duplicate custom service configuration in .NET core

In my current .NET Core project, I want to inject two services into my controllers for dependency injection. I wrote the following extension methods that each takes a ...
1
vote
0answers
2k views

Prism 6 Popup Window with EventAggregator to replace a service

I have a WPF project with Prism 6 and EF6. In my project I have a MainTabModule which has ...
1
vote
0answers
1k views

MVC application internationalization using a database provider and dependency injection

Following Nadeem Afana's article about how to include internationalization into an MVC application, I have introduced i18n into one of my MVC applications. These ...
1
vote
0answers
102 views

PHP Dependency Injection Container

I am currently working on a small framework and one of its main components is a dependency injection container I made. I am not a professional dev and I would like someone more experienced than I am ...
1
vote
0answers
30 views

Return four spreadsheets of Google Analytics account, property, profile, and filter information

Scenario goes like this: User enables plugin from within Google Spreadsheet Authenticates with their Google Analytics Account They select which accounts they'd like to perform an audit on Four ...
1
vote
0answers
90 views

OOP QueryHandler in PHP

I have a simple database connection class which is using PDO: ...
1
vote
0answers
52 views

Injecting required functions by synchronous script loading

I have a file HintBox.js containing a JS prototype of the same name which requires our internal JS library (call it $lib) in ...
1
vote
0answers
207 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 import-...
0
votes
0answers
71 views

Extremely lightweight dependency injection

I need to have access to a set of common data inside a few functions. The data values are determined only at runtime, and are far away in terms of control flow, so handing them to the function as an ...
0
votes
0answers
31 views

Business logic refactoring needed

I am using asp.net web API and EF code first. I am querying the database based on values inside of the request object (initiate). If there are results, I am updating the database. Then I am querying ...
0
votes
0answers
38 views

Class to create and send a PDF form with attached documents

I'm currently working on building a class to create a PDF form application with attached documents and sending that file to an endpoint in Box Api. I have found extremely difficult managing ...
0
votes
0answers
62 views

Inject settings as a dependency, and serve them using a Web API

I used an opportunity to learn about Dependency Injection and DDD, therefore, althought any feedback is welcome, I am interested in feedback about those software design principles. I have a small ...
0
votes
0answers
494 views

Dependency Injection and Service Locator/DI Container

I have implemented clean architecture for my app, and I have a few questions. Typically, pure DI is argued for over a Service Locator pattern, because it is very explicit and more testable. However, ...