Dependency Inversion Principle
This is described on p61 but I don't think the book has demonstrated the intent of the pattern "properly" in code.
The higher level module should define an interface describing the services it requires from a lower level module. The interface should be in the same namespace/package as the higher level module - not associated with the lower level module.
The idea is that the higher level module defines it's required services in terms of it's own business objects and does not rely on low level/3rd party provider APIs.
It's really an example of an adapter pattern.
In the example shown we've simply extracted interfaces for the entire lower level modules without without making this distinction.
|