mardi 15 janvier 2019

how spring is more efficient than factory pattern in decoupling the classes

one of the most important features of spring is that it provides decoupling using dependency injection. like I have an interface Vehicle and I have its implementations like Car, Bus, Bike. so I can configure these beans in spring and can assign any implementations out of Car, Bus, Bike into Vehicle. so the code is loose coupled here. but same thing we can achieve here using factory pattern, in this way also we will have to change the code at the place while passing the information to the factory method. so I want to know that how spring is more efficient here ?

Aucun commentaire:

Enregistrer un commentaire