https://kotlinlang.org logo
Title
p

Paul Woitaschek

11/02/2018, 3:56 PM
So a realistic example:
purchaseCardContents
calls
purchaseCardContents
which calls
toPurchaseCardContent
several times. Now I need a class
FormatSavings
in the last function
toPurchaseCardContent
. How do I get it there? When using a class for the whole logic, I just inject it through the constructor. The issue here is that
toPurchaseCardContent
doesn't know anything about
purchaseCardContents
so I would need to pass-through that class and everything else it needs. Maybe the better question is: How do I get / pass dependencies I don't want the caller to bother about in functional programming?
l

louiscad

11/02/2018, 4:04 PM
This code seems to have a quite narrow scope, I don't see how you could make something generic or apply some pattern I know (I don't know all of them though, far from this)
I think I'd have a
FormatParams
class if I had your use case