3 ms·
It lets you constrain your logic code to depend as loosely as possible on its dependencies. If I start from a concrete 'FooDatabase' (and wait until later to i
by mrkeen 7y ago
It lets you constrain your logic code to depend as loosely as possible on its dependencies.
If I start from a concrete 'FooDatabase' (and wait until later to interface it), I might start putting things like open(), close(), flush(), etc. into my logic code. Then when I interface it, it will just be unnecessary indirection.
If I start from the other end and think "I just need somewhere to put my Foos", then I'll pass in a Consumer<Foo> and be done with it.