Answer the question
In order to leave comments, you need to log in
What is the reverse double dispatch pattern called?
It is known that the essence of double dispatching is to choose the most appropriate method depending on the arguments. Those. slightly more flexible method overloading implemented by the visitor.
In my case, the most appropriate argument is selected from the DI container and slipped into the method, following its signature. Something like autowiring in Spring and Symfony.
Pseudocode:
// Регистрация в контейнере
container = new Container();
container.registerInstance(UserRepositoryInterface, repository);
// Сам класс
class Some {
method(UserRepositoryInterface users) { ... }
}
// Непосредственно вызов
some = new Some();
container.callMethod(some, "method");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question