For this part of the course project, you will be incorporating the Mediator pattern into your traffic flow system.
The class that you develop will coordinate the intersection and the four traffic lights.
This class will be responsible for queuing requests and making sure that each light is green for a minimum amount of time.
The Mediator design pattern enables decoupling of objects by introducing a layer in between the various objects so that the interaction between objects can happen by means of the layer. In an enterprise application where we have a large number of classes, the complexity also increases as the size of the project increases.
The business logic might be spread across several classes and there will be interaction between classes. If we draw an interaction line between these classes where we have interaction, it will become difficult to decipher what is going on. Before application of the Mediator pattern, there exists complex interaction between objects, and this creates dependency and tighter coupling.
Our objective is to achieve loose coupling, and we want to reduce dependency as much as possible while increasing reusability.