RepositoryFactory using Dependency Injection?

Jun 11, 2008 at 12:39 PM

Hi Tim,

 

Is the process you use to instantiate the concrete repository in your RepositoryFactory class known as Dependency Injection? I have heard many phrases like Inversion of control and Dependency Injection on the Domain Driven Design forum but I wanted to know if you were using it in SmartCA?

 

Loving the Book by the way!
Scott

Coordinator
Jun 13, 2008 at 9:52 PM
Edited Jun 18, 2008 at 4:57 PM

Scott, first of all, thanks for the compliment and thanks for buying my book!

No, I am not using dependency injection.  What I am doing with the RepositoryFactory class is a combination of the Separated Interface pattern from Fowler and the Factory Method pattern.

Thanks,

Tim


Scott_Millett wrote:

Hi Tim,

 

Is the process you use to instantiate the concrete repository in your RepositoryFactory class known as Dependency Injection? I have heard many phrases like Inversion of control and Dependency Injection on the Domain Driven Design forum but I wanted to know if you were using it in SmartCA?

 

Loving the Book by the way!
Scott




Jun 20, 2008 at 1:14 PM
Ok thanks Tim. So what is the difference between what you are doing and Dependancy Injection? With Dependancy Injection would all references to the IRepository be replaced with a concrete instance at runtime automatically without the need to call a factory method? If so why didn't you do this?


tmccart1 wrote:

Scott, first of all, thanks for the compliment and thanks for buying my book!

No, I am not using dependency injection.  What I am doing with the RepositoryFactory class is a combination of the Separated Interface pattern from Fowler and the Factory Method pattern.

Thanks,

Tim


Scott_Millett wrote:

Hi Tim,

 

Is the process you use to instantiate the concrete repository in your RepositoryFactory class known as Dependency Injection? I have heard many phrases like Inversion of control and Dependency Injection on the Domain Driven Design forum but I wanted to know if you were using it in SmartCA?

 

Loving the Book by the way!
Scott







Coordinator
Jun 24, 2008 at 10:00 PM
Scott,

I think that my solution is more flexible; whenever I want a particular instance of one of my repositories I just ask the RepositoryFactory for it and it is created based on the configuration values for the repositories.  According to Martin Fowler's definition, the choice between my way and using dependency injection is less important than the concept of separating configuration from use. 

Interestingly, I am actually injecting the IUnitOfWork interface into my repositories via the RepositoryFactory's GetRepository method... 


Scott_Millett wrote:
Ok thanks Tim. So what is the difference between what you are doing and Dependancy Injection? With Dependancy Injection would all references to the IRepository be replaced with a concrete instance at runtime automatically without the need to call a factory method? If so why didn't you do this?


tmccart1 wrote:

Scott, first of all, thanks for the compliment and thanks for buying my book!

No, I am not using dependency injection.  What I am doing with the RepositoryFactory class is a combination of the Separated Interface pattern from Fowler and the Factory Method pattern.

Thanks,

Tim


Scott_Millett wrote:

Hi Tim,

 

Is the process you use to instantiate the concrete repository in your RepositoryFactory class known as Dependency Injection? I have heard many phrases like Inversion of control and Dependency Injection on the Domain Driven Design forum but I wanted to know if you were using it in SmartCA?

 

Loving the Book by the way!
Scott