Answer the question
In order to leave comments, you need to log in
How to deal with dependency inversion?
I read a recent article about SOLID. The example in the article is clear to me, but one thing is not clear. In the section where the author starts talking about dependency inversion, there is a paragraph:
To do this, in his C module, he created an interface, and wrote a simple adapter that takes a dependency from the desired module and provides access only to the desired method. Now if you fix something, you can fix the "breakdown" in one place.
Answer the question
In order to leave comments, you need to log in
What is an adapter?
public function changePassword(string $password, PasswordEncoder $encoder)
{
$this->password = $encoder->encode($password);
}
https://ru.wikipedia.org/wiki/Adapter_(project_template...
What does "accept addiction" mean?Gets another object needed for its operation.
And how did it suddenly happen that now it will be possible to fix the "breakdown" in one place?C and B now have dependencies on different adapter classes of module E, and by interface from their own module, rather than direct dependencies.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question