What is dependency injection

123 viewsOtherTechnology

What is dependency injection

In: Technology

6 Answers

Anonymous 0 Comments

It makes it simpler to deal with dependencies that have dependencies of their own. Let’s use a database access object (DAO) as an example. To create the DAO, you need to tell it how to to access the database. If you need to use this DAO in another part of the program, then that file also needs to know how to access the database in order to initialize the DAO.

Instead of doing that, you can initialize the DAO and designate it as an injectable object, and then everywhere else in the program where you need to use that DAO, you just indicate that it needs the DAO and the dependency injection adds it in during initialization.

You are viewing 1 out of 6 answers, click here to view all answers.