I have a class (let's call it MyService
) that accepts two dependencies in it's constructor. The first one is not all that relevant to the question. The second one is PaymentDetails
. PaymentDetails lives for longer than the MyService, which is created by a factory to process this particular request.
In MyService.process()
, it:
- does some stuff with the first dependency,
- constructs a
new TransactionDetails()
object and sets various things on it, - calls
myPaymentDetails.setTransactionDetails( td );
- returns something to say which page in the wizard follows next
PaymentDetails
has by necessity many methods on it. It is an Entity style object into which information is built up as the user steps through a series of about 5 pages.
What is bothering me is that as written my service class depends on the whole of PaymentDetails
but only calls one single method.
This bothers me because:
- it will limit the ability to re-use the service class
- it is not possible to understand what the real dependencies are by reading the method signatures
My question is:
What is the best way to fix this so that my service class has minimal dependencies?