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
JavaBot
JavaBot11mo ago
This post has been reserved for your question.
Hey @Rag...JN 🌌 🦡 👽 💰! Please use /close or the Close 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Rag...JN 🌌 🦡 👽 💰 🐊
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
@Override
protected void fireActionPerformed(ActionEvent actionEvent) {
mediator.addNewNote(new Note());
}
@Override
protected void fireActionPerformed(ActionEvent actionEvent) {
mediator.addNewNote(new Note());
}
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
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Rag...JN 🌌 🦡 👽 💰 🐊
oh ok that make sense
Rag...JN 🌌 🦡 👽 💰 🐊
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.
Rag...JN 🌌 🦡 👽 💰 🐊
so what are the problems we will be facing if you didn't use the Pattern here? what problem it solves?
JavaBot
JavaBot11mo ago
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.
Rag...JN 🌌 🦡 👽 💰 🐊
no please don't delette
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Rag...JN 🌌 🦡 👽 💰 🐊
Ok yah I found the page later So instead of coupling components you have a mediator
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Rag...JN 🌌 🦡 👽 💰 🐊
I tried to mimic what would be the problem if I didn't use the Mediator pattern
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Rag...JN 🌌 🦡 👽 💰 🐊
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
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Rag...JN 🌌 🦡 👽 💰 🐊
hi @Fischstaebchen I created one but it's kinda big
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot11mo ago
💤 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.
Want results from more Discord servers?
Add your server