Answer the question
In order to leave comments, you need to log in
Difference of Open\Closed from Dependency Inversion?
DIP forces code to be dependent on abstractions rather than specific implementations.
Open\Closed makes the code closed for modification, but open for extension. By using abstractions instead of concrete dependencies.
So what's the difference? Can DIP violate OCP?
Answer the question
In order to leave comments, you need to log in
DIP is when code depends on abstractions rather than implementations.
OCP is when we design our code with room to extend through inheritance/implementation of interfaces, for example, but not only.
You can safely follow DIP while violating OCP and vice versa.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question