Answer the question
In order to leave comments, you need to log in
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
I constantly forget patterns, and from time to time I refresh them in my memory
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 questionAsk a Question
731 491 924 answers to any question