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

  • Home
  • SEARCH
  • 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 8428227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:59:42+00:00 2026-06-10T04:59:42+00:00

I have a very small app which i am using to learn design patterns.

  • 0

I have a very small app which i am using to learn design patterns.

Currently I am trying to implement a dependcy injection container but it just feels like a factory.

Can someone explain what is wrong with the container and where it can be improved.

As i said its very minimal and the app only requires a couple of objects:

class MyContainer
{
    public function getObjectA()
    {
        return new MyObjectA();
    }

    public function getObjectB()
    {
        $objectBArrayParam = array('arrparam1','arrparam2', 'arrparam3', 'arrparam4');
        $objectB = new MyObjectB('param1','param2', 'param3', 'param4', $objectBArrayParam);
        return $objectB;
    }

    public function getApplicationRunner()
    {
        $objectA = $this->getObjectA();
        $objectB = $this->getObjectB();

        $app = new ApplicationRunner($obejctA, $objectB);

        return $app;
    }

}
  • 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-06-10T04:59:43+00:00Added an answer on June 10, 2026 at 4:59 am

    A factory could be seen as a static type of Dependency Injection. You’re specifying the arguments at compile time and the resulting object graph is always the same.

    A dependency injection tool would use some kind of reflection to check at runtime what arguments are needed. Then it would search for the required types in its configuration and construct the object graph for you.

    If you want to build a simple DI container you need to create support for registering types and for checking required types at runtime.

    Something like:

    myDi.Register(<typeofIObectA>).To(<typeofobjectA>)
    myDi.Register(<typeofIObjectB>).To(<typeofobjectB>)
    
    MyDi.Resolve(<typofApplicationRunner>)
    

    The DI container would see that ApplicationRunner needs two arguments. It would check the configuration for those types and thn construct the objects.

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

Sidebar

Related Questions

i have a very small utilty app written in c# that works fine on
I used to have a small chat app(which was almost working), that uses PHP,
Im using a large amount of very small web services in my app and
I have a website which contains a small Silverlight plugin that calls a very
Hi I'm developing a small web app in which I have and embed video
I'm using forms authentication on a very small ASP.NET web app (Web Forms) in
I'm working on the design of a web app which will be using AJAX
I have a very small form where a user can enter their zip code
I have a very small office environment, and my team sends created pdfs to
I have a very small program: public static void main(String[] args) { Queue<String> queue

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.