Search Results

Search found 1 results on 1 pages for 'eeerahul'.

Page 1/1 | 1 

  • Can observer pattern be represented by cars and traffic lights?

    - by eeerahul
    I wanted to verify with all of you, if I have a correct Observer Pattern analogy. The scenario is as follows: Consider, at a junction, there is a traffic signal, having red, yellow and green lights respectively. There are vehicles facing the traffic signal post. When it shows red, the vehicles stop, when it shows green, the vehicles move on. In case, it is yellow, the driver must decide whether to go or to stop, depending on whether he/she has crossed the stop line or not. At the same time, there are vehicles that do not care about the signal. They would do as they like. The similarities are that, the Traffic Signal happens to be the subject, notifying its states by glowing the appropriate lights. Those looking at it and following the signal are the ones subscribed to it, and behave according to the state of the subject. Those who do not care about it, are sort-of un-subscribed from the traffic signal. Please tell me, if you think this is a correct analogy or not?

    Read the article

1