The short question is: is it true that for Observer Pattern to work, there probably is some polling mechanism underneath? (update: in a network situation)
It was quite amazing that if on my Macbook Pro, I save a file
Hello World.txt into the Dropbox folder, then I actually see it appearing on my other Macbook within 1 second or 2.
It is even more amazing that, on the other Macbook, if I do a search on
Hello as a name match, and that
Hello World.txt showed up there as a search result, and now I go to my Macbook Pro and rename the file as
Hello World HiHi.txt, after 1 second or 2, then the new name actually showed up in the search result of the other Macbook. That is, the search results probably observe on any folder changes, and folder observes on the Dropbox state changes remotely on the Dropbox website.
So I am guessing that the Dropbox app probably has a 2-way TCP/IP connection so that, the Dropbox server can initiate a message to my Macbook's Dropbox background app, saying "Hey, your folder content has changed on the server", and then the Dropbox background app on my Macbook will do the rename, and my folder object (the model, or the data object) will then notify the search folder object, "Hey, my content has changed", and the search folder object will then notify the folder view object, saying, "Hey, the search result has changed (and so you probably want to update the view on the screen)".
So I think this maybe roughly how it worked? But the question is, if there was no TCP/IP two-way connection, then is it true that the Dropbox background app will have to poll the Dropbox server every 1 or 2 seconds to ask "did something changed?" And that will be too busy for the Dropbox server.
However, isn't it true that even though there is a two-way communication set up, some where down beneath the TCP/IP layers (the 7 OSI layers), there is some kind of polling?
For example, the Dropbox server, at the very low level, cannot push an electron to my router, notifying my Macbook, because what if there is a firewall, then somehow, on my side, there must be some kind of polling at low level, or else the Dropbox server cannot push through my firewall.
Or, if viewed this way: if I am using WiFi on my Macbook, there probably is no mechanism of Dropbox server pushing something to my wireless router, and then use electromagnetic wave to push to my Macbook, to notify me? That is, my Macbook has to constantly ask the wireless router, "any thing new for me?" Because if the Macbook doesn't ask -- if the Macbook crashed or if the Macbook wireless firmware crashed and is not asking, there really is no "pushing of data" from the wireless router to the Macbook. The Macbook really has to "constantly ask".
Update: I don't mean polling necessary to the server, but I just mean some kind of mechanism has to constantly look to see if anything new, versus if it is Observer Pattern inside of code in an app, then the CPU will just "jump" to the code to execute the observer's code, and therefore the observer really has to do nothing. But for Observer pattern over a network, what I mean is, say, if you have your notebook computer using Wifi, and you turn off your Wifi, then the Observer Pattern will not work. Now you turn on the Wifi, but the Wifi firmware or hardware really has to constantly "sense" whether something new has come in, because Wifi signal has no way to "force into the computer", not like the Intel Processor can just "jump" to a chunk of code. So if either firmware or hardware has to constantly "sense" whether there is something new, that's what I mean by polling -- the Observer cannot be totally waiting; some mechanism has to constantly check for something.