U
U
user_of_toster2021-03-11 14:52:59
OOP
user_of_toster, 2021-03-11 14:52:59

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

2 answer(s)
V
Vasily Bannikov, 2021-03-11
@user_of_toster

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.

Z
zoozag, 2018-01-11
@Yastr

This is not easy to do, because the tags are stored as a single line, and when searching, the occurrence of the search text in this line is checked:
It is implemented like the standard search via the getProducts method in the catalog/product model.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question