K
K
Kirill Nesmeyanov2017-09-05 23:03:40
Design patterns
Kirill Nesmeyanov, 2017-09-05 23:03:40

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");

Those. the "method" method is called, using some matching pattern for the arguments.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2017-09-06
@Nipheris

Multimethod

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question