D
D
dllweb2018-02-04 09:17:52
PHP
dllweb, 2018-02-04 09:17:52

Design pattern - mediator (Mediator) explain with a simple example how it works?

Hello everyone, I constantly forget the patterns, and from time to time I refresh them in my memory, but now there is a problem with the mediator pattern, I'm confused, tell me an example, the most concise and simple. So to say, open the essence of it in one post with a code example, please, who is not difficult

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Ken Jee, 2018-02-04
@Machez

I'll just leave it here https://proglib.io/p/behavioral

M
Maxim Fedorov, 2018-02-04
@qonand

I constantly forget patterns, and from time to time I refresh them in my memory

and you should not fill your head with unnecessary information and memorize them all and in all details. It is enough to understand what they are and what tasks each of them solves. And if necessary, look for more specific information on them.
For GoF patterns, I can advise designpatternsphp.readthedocs.io/ru/latest/Behavio...

A
AlexHell, 2018-02-14
@AlexHell

if I'm not mistaken, I'll give an example from game development: a list of slots SlotList, and the slot Slot itself, here is a colleague (colleague) is Slot and there are a lot of them, and the mediator (mediator) is SlotList i.e. an intermediary that coordinates all the slots, and we pass the click event on (x, y) on the stage to the mediator, and it decides which slot we are in (for example, it compares the bounding box in a loop), we can also contact the mediator to fill in its list of slots, for example pass some Dto or a list of Dtos for visualization in slots, and the mediator will place its own image and text in each slot,
here is another example (but I didn’t understand it in detail) https://github.com/marwie/Design-Patterns-in- Unity...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question