I’m currently reading Head First Design Patterns and I’m really loving their style of writing. They mention that most of the time you will roll your own implementations of Observable (the class that pushes out updates) and Observer (the classes that act on these updates. This is what I’ve seen in my time as a developer too but the JDK also offers the Observable class and the Observer Interface that you can use to do the same.
Unfortunately they have not been updated in a long time and have some issues including:
- Observable being a concrete class
- Observable using the deprecated Vector class as the holder for Observers
- Not using generics to make the code cleaner looking
I’m not sure if my experiments with modifying these classes can be called an improvement but they are up on Github and it was an interesting exercise.