News for hackers. Stuff that matters.
Re:Understanding SOLID Principles: Dependency Inversion by julian_1 on Wednesday October 04, 2017 @04:01PM (#15404016)
You can even do it(in fact it's a common pattern) using partial application. Configure a function by binding its first argument with some config data/behavior/policy/mock etc. This eliminates the first arg of the function signature and generalizes it. Then pass that function off to another higher-order function. The advantage is the consuming function is isolated and knows nothing about the composed behavior - even during construction.

In this case the function signature corresponds to the class interface, and partial application corresponds with binding the injected dependencies passed via the constructor (using a factory, or dependency injection container etc).

There are no comments on this comment yet.