Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traffic Signal System: observer design pattern improper usage #62

Open
siddharthmagadum16 opened this issue Dec 25, 2024 · 0 comments
Open

Comments

@siddharthmagadum16
Copy link

Hi Ashish, I was going through LLD of Traffic Signal System. The design uses observer pattern, but I think that this is slightly misimplemented.


The Code here, i.e. notifyObservers() should not be present in TrafficLight entity.

Rather, it should be called in TrafficController entity, as it has the list of Roads (indirectly TrafficLights) and acts as a subject to infrom all TrafficLights about the signal color update of each of them.


In short, `notifyObservers()` method should be a part of TrafficController and `listenTrafficEvent()/changeColor()` should be part of TrafficLight.
@siddharthmagadum16 siddharthmagadum16 changed the title Traffice Signal System: observer design pattern improper use. Traffic Signal System: observer design pattern improper usage Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant