Example class diagram
Let's imagine that we are building a system for a school where each student can take multiple classes and each class is taken by multiple students. We might want to have a functionality that notifies all the students of a specific class that it is canceled, or we might want to easily add or remove users from classes. We can impulsively start writing our code and have a list of classes as a part of the student class and a list of students in the group class. This way, however, our objects will become interconnected and not really reusable. This is a good use case for the mediator pattern.
Let's take a look at our class diagram:
As you can see from the preceding diagram, the school is the mediator and it contains information ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access