Nowadays, the Observer pattern is one of the most common software design patterns on the scene. It's based on the concept of subject. A subject is a particular object that keeps a list of objects that want to be notified when the subject changes. These objects are called Observers and they expose a notification method that the subject invokes when its state changes.
In the previous chapter, we saw the spreadsheet example. Now we can expand the example, showing a more complex scenario. Let's think about a spreadsheet containing the accounting data. We could represent this data as a table, as a 3D-histogram, or as a pie chart. Every one of these representations will depend on the same set of data being displayed. Every one of these representations will be an Observer, depending on one single subject, maintaining all the information.
The 3D-histogram class, the pie chart class, the table class, and the class maintaining the data are perfectly decoupled: they can be used and...