❔ Can someone help me understand this statement around dependency inversion with an example?
I was refreshing my memory on SOLID based on conversations in #chat today, and a particular statement is hurting my head this evening:
High-level modules should not depend on low-level modules. Both should depend on abstractions.I'm wondering, can someone share a simple example that demonstrates how both can depend on abstractions? I think I'm just overthinking it at the moment.
4 Replies
For clarity, the both part throws me off.
I found another article that says what I currently do is fine
So something like:
My understanding is that this is fine since I'm consuming the user service through an interface instead of interacting with
CachedUserService
directly.yeap
your Sample doesn't need to know if there is any cache system
yeah, essentially you have a layer of implementations which inherits from an accompanying layer of abstractions
when you have to use something from that layer you register dependencies in a module and you're done
ymmv depending on where those abstractions are, sometimes architecture could be more sophisticated than that
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.