I take the prototype scoped beans as an alternative to the factory classes used to create objects. The difference is that in the case of the beans spring prototype, you save some code for dependency injection, and also automatically proxy your objects for transactions, etc., when necessary.
I myself prefer the factory approach. One of the reasonable scenarios for the prototype area that I came across was a stateful object, needed for different famous beans, and each of them required its own copy. The highlighted factory class will be redundant in this scenario, since I donβt need to create objects on the fly, but only when using other beans. "
mrembisz
source share