Widget oPooledWidget = (Widget)oObjectPool.borrowObject(); Widget oInjectedWidget = oAppContext.getBeans("widget"); Widget oFactoryWidget = oWidgetFactory.createWidget(); Many different ways exist to instantiate classes without the new operator and a constructor, and I'm looking for the generally-accepted use cases/scenarios for when to choose one over the other.
Obviously it is not appropriate to pool objects in certain circumstances, such as when you either have no idea how big the pool could get, or when you know the pool would be huge.
But what is an appropriate scenario that calls for pooling? When does pooling offer benefits over dependency injection or factory classes?
Similarly, when would one want to choose using a factory class over dependency injection, and vice versa?