其实我也不太明白大侠说的意思,。
所以下面抄点关于观察器范式的形容。不知是否
适合你的情况。
In our new, more sophisticated windowing world, we often would
like to display data in more than one form at the same time and have all of the
displays reflect any changes in that data. For example, you might represent
stock price changes both as a graph and as a table or list box. Each time the
price changes, we’d expect both representations to change at once without
any action on our part.
We expect this sort of behavior because there are any number of
Windows applications, like Excel, where we see that behavior. Now there is
nothing inherent in Windows to allow this activity and, as you may know,
programming directly in Windows in C or C++ is pretty complicated. In Java,
however, we can easily make use of the Observer Design Pattern to cause our
program to behave in this way.
The Observer pattern assumes that the object containing the data is
separate from the objects that display the data, and that these display objects
observe changes in that data.