Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 849029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:02:16+00:00 2026-05-15T07:02:16+00:00

I recently ran across this great article by Chad Parry entitled DIY-DI or Do-It-Yourself

  • 0

I recently ran across this great article by Chad Parry entitled “DIY-DI” or “Do-It-Yourself Dependency Injection”. I’m in a position where I’m not yet ready to use a IoC framework, but I want to head in that direction. It seems like DIY-DI is a good first step.

However, after reading the article, I’m still a little confused about object creation. Here’s a simple example:
enter image description here

Using manual constructor dependency injection (not DIY-DI), this is how one must construct a Hotel object:

PowerGrid powerGrid;           // only one in the entire application
WaterSupply waterSupply;   // only one in the entire application

Staff staff;
Rooms rooms;
Hotel hotel(staff, rooms, powerGrid, waterSupply);

Creating all of these dependency objects makes it difficult to construct the Hotel object in isolation, which means that writing unit tests for Hotel will be difficult.

Does using DIY-DI make it easier?
What advantage does DIY-DI provide over manual constructor dependency injection?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:02:16+00:00Added an answer on May 15, 2026 at 7:02 am

    There’s no difference between what you call DIY-DI and manual constructor injection.

    If it’s too difficult creating a Hotel instance you can do two things:

    • Make sure that the dependencies are expressed as either interfaces or abstract base classes. This lets you test the Hotel class in isolation by providing Test Doubles such as dynamic mocks or similar instead of concrete classes.
    • If there are too many dependencies, then refactor to aggregate services.

    As an application grows in complexity, so does the task of managing the lifetimes of all dependencies. While it’s technically possible to manually compose an entire application, this is exactly the point where a DI Container can be extremely helpful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently ran across this article that explains how to center content with only
I recently ran across this puzzle, was finally able to struggle out a hacky
I recently ran across a routine that looks something like this: procedure TMyForm.DoSomething(list: TList<TMyObject>;
I recently ran across this problem while trying to implement a service that has
I recently ran across this code in one of the projects I'm working on,
Ran across this recently and wondering if someone out there can give me a
I ran across this code recently which is part of a template class: operator
Recently I ran across a blog article about using PHP scripts to redirect affiliate
So I ran across this recently: http://www.nicalis.com/ And I was curious: Is there a
I recently ran into this problem: Rails 3 link_to (:method => :delete) not working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.