lundi 30 avril 2018

Can Dependency Injection be considered to be a replacement for factory method pattern?

According to wikipedia

In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created.

In dependency injection also(I have experience of spring so this may be in that context), we have Variables for each class defined using interfaces, and leave the concrete instantiation to the DI framework.

Am I missing something in this or can these be used interchangeably?

Aucun commentaire:

Enregistrer un commentaire