Wednesday, August 3, 2005

Hints on Listeners

The Observer pattern, most often seen in Swing development, is also very useful for decoupling components in situations other than GUI applications. However, some common pitfalls with registering or invoking listeners exist. In this installment of Java theory and practice, Java therapist Brian Goetz offers some feel-good advice on how to be a good listener -- and how to be nice to your listeners, too.
rating comment: This article covers a lot of useful hints on listeners. Especially the thread-safty issue is one of the most dangerous sources of error, which I can definitely relate to. But personally I think the biggest problem is what the author calls "Lapsed listeners", cause if you don't deregister listeners, you'll certainly run into problems, especially if you have large Swing applications.

No comments: