I am making a web application with a group using Websphere Liberty Server.
We have chosen to use the DataMapper design pattern for accessing the underlying database. We have a couple of different DataMappers each with their own interface.
Right now when we need to use a service, we inject the mappers needed in the service through the constructor of the service.
This works, and it's very easy to test but we can't figure out if it's the right way to do it? Should we really make new instances of both service and mapper all the time, when both of them are stateless?
Or would it be better to use a factory? Which could somehow contain singletons of all, while still making everything easily testable?
Aucun commentaire:
Enregistrer un commentaire