Rewriting Observer / Observable using generics

You are not authorized to post comments.
Session Type: 
Standard [35 minutes]

The class java.util.Observable and the interface java.util.Observer have existed as part of the Java SE since version 1.0. They provide a simple framework for the Observer/Observable pattern. However, they do not use Java generics as of JSE v7. In contrast, many other classes -- java.util.Collection hierarchy, for example -- were retrofitted, indeed rewritten, after generics were made a part of the language.

In this talk, I'll show how you can write your own simple implementation of the Observer pattern using generics. I'll show you the code and a reference implementation; and provide some suggestions on how to write type-safe code in Java.

Schedule info



Cool Stuff (Other)
Experience level: 

"Talk" is appropriate

I am happy to do this as a "Talk".
My plan with the 3 hour session was to show the surprising (and sometimes humorous) results that arise from careless use of Java's generics. In the 35-minute "Talk" format, I'd simply stick to the Observable/Observer pattern and skip the more esoteric generics stuff.

Tutorial or Talk?

This submission is currently marked as 3h tutorial. Did you intent to submit this as a regular session?

Copyright © 2013 The Eclipse Foundation. All Rights Reserved.