From the course: Complete Guide to Java Design Patterns: Creational, Behavioral, and Structural

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Avoid tight coupling between objects

Avoid tight coupling between objects

This app is an example of where objects are tightly coupled and would benefit from using the mediator pattern. It's an app for keeping track of tickets that developers are working on, and there are three main classes. The first one is the ticket class, so this class has a field of type assignee, which is the person who's working on the ticket. Then there's an enum called status, so a ticket can either be submitted, in progress, or done. And then there's a field to store the status. And you can see in the constructor that when you first create a ticket the status is set to submitted. Then there's a method to get the status and method to set the status, and a method to set the assignee. Next there's the board class. So this is the board where tickets are kept. There are two lists, one called inProgressTickets, which is an array list, and another array list called doneTickets. Then there's a method to get the done tickets, and there's a method called addTicketToInProgressTickets. So this…

Contents