Mediator Pattern Code How does this code actually built because it's not actually straight forward
So I am following this code example for mediator pattern
https://refactoring.guru/design-patterns/mediator/java/example
Mediator in Java / Design Patterns
Mediator pattern in Java. Full code example in Java with detailed comments and explanation. Mediator is a behavioral design pattern that reduces coupling between components of a program by making them communicate indirectly, through a special mediator object.
20 Replies
⌛
This post has been reserved for your question.
Hey @Rag...JN 🌌 🦡 👽 💰! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
So my question is it's not like you can define the Mediator interface from the start
First you just declare the interface?
but if you see the code example order for each class
It starts with Component but the component has already Mediator defined
now if you go to the AddButton class which is next, you can see
mediator.addNewNote is called
but this is just the second class yet I haven't declared a addNewNote in the Mediator interface
and also that method addNewNote which takes a Note class
which I haven't even created
So I am confused about how it actually gets built
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
oh ok that make sense
Mediator Design Pattern in Java | DigitalOcean
Technical tutorials, Q&A, events — This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
so what are the problems we will be facing if you didn't use the Pattern here?
what problem it solves?
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
no please don't delette
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Ok yah I found the page later
So instead of coupling components you have a mediator
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I tried to mimic what would be the problem if I didn't use the Mediator pattern
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
yah I failed
but I later understood the entire Component, Mediator, Collegues thing
Currently I have a sample exam question to solve I am going to work on this
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
hi
@Fischstaebchen I created one but it's kinda big
GitHub
design_pattern_practicals/src/main/java/com/rag/practicals/mediator...
Java Design Pattern Practicals. Contribute to ragujan/design_pattern_practicals development by creating an account on GitHub.
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.