On 05/04/2011 13:16, Paulo Pinto wrote:
Most Java developers do.
I code mostly in Java and really hate when I see code like this, but somehow
the
pattern of using anonymous classes in-place for event handlers has got into
the mind
of many developers.
You will find thousands of such examples when searching for Java GUI
examples, either
in SWT or Swing.
What's wrong with such pattern in Java? There aren't much alternatives
in Java, what would you use instead? A nested class? Or use the outer
class itself as the handler, by having it implement the handler interface?
I find that using the anonymous class in-place is the cleanest in most
situations.
--
Bruno Medeiros - Software Engineer