• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Abstract factory worth it when working with dependency injection?

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tend to think that the effort of implementing and maintaining a design with the abstract factory pattern might not be worth it when you have a dependency injection framwork like Spring. At least not when the deployed application is going to use only one implementation of the factory. Instead of creting the objects in a factory, I'd have them injected. A different configuration file would be used to inject a different set of objects (alternative implementation). Yes, it would be easier to just inject a factory and not each object, but you'd still have to write the concrete factories with the code to instantiate all those objects. So, is it worth it? what do you guys say?
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why Dependency Injection is better than Factory?
 
greg buela
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I guess I was making sense.
 
reply
    Bookmark Topic Watch Topic
  • New Topic