commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael L. Heuer" <>
Subject Re: [collections] simple collections event package + decorators
Date Fri, 23 May 2003 14:27:36 GMT

On Thu, 22 May 2003, Stephen Colebourne wrote:

> I do view it as being low impact, in terms of simple code, few objects
> created, small performance impact. Support for more detailed events needs to
> be built into the implementation, not added as a decorator IMO.

The key thing is that the listeners receive notification.

Imagine a simple case where you have a label that wishes to receive
notification of when a Collection changes,

Results (0)

collection.addCollectionListener(new CollectionListener()
  private void updateLabel()
    results.setText("Results (" + collection.size() + ")");

  public void elementsAdded(CollectionEvent e) { updateLabel(); }
  public void elementsRemoved(CollectionEvent e) { updateLabel(); }
  public void cleared(CollectionEvent e) { updateLabel(); }

Complicated implementation in the decorator to describe to this listener
exactly what changed is overkill.

I think it's better to put the responsibilty on the receiver -- if there
is a case where a listener needs to know the exact details, it can clone
the Collection at each event notification and calculate the difference(s)

Of course, the best thing is some sort of middle ground, where the event
describes the change to a sufficient level of detail to make most things

What is the line, make the simple case fast and the hard one possible?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message