3 ms·
>One better solution in TFA's example is to pass a high-order function whose "functionality" is to provide the time. Having a function or an interface as an ar
by hackinthebochs 14y ago
>One better solution in TFA's example is to pass a high-order function whose "functionality" is to provide the time.
Having a function or an interface as an argument is functionally equivalent. In fact, the interface is more expressive than the function as it describes more behavior than a simple function does. In both cases there is an "inversion of control" where the caller has to specify what object is passed in. So claiming that one is better than the other seems more personal preference than fact.