There is a trade object, it is currently saved to a file system. The details (filename, location) are filled in a dialog (swt). I'm introducing tests for this logic and I'm introducing a service layer. There will be a TradeService interface which will have methods to persist the trade.
When I'm running my unit tests, I will be subbing in a TransientTradeService which keeps a handle of trades in a HashMap. In production, we will use FileTradeService which actually saves stuff to disc.
Thing is, the FileTradeService needs the extra details mentioned. How to handle this? My solution was to invert control to the TradeService - essentially by passing in the current widget which will allow TradeService implementations which need more details from the user to be able to ask for them from the user.
On one hand seems neat, but also seems odd by service layer having a dependency on the ui. Is this something to be worried about? If so, any other solutions?
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
a bit of art, as a gift, the permaculture playing cards