<Swing Dev> 6179357: Generics: JList: Constructors & Model
fbrunnerlist at gmx.ch
Fri Mar 13 16:14:30 PDT 2009
I just received a copy of Joshua Bloch's book "Effective Java - Second Edition" this week (of course
I already own a copy of the first edition ;-) ) and could read about the PECS mnemonic. :-)
I think you're right that in many cases a model is both a producer and a consumer, but I think in
the case of the immutable ListModel, it's actually just a producer.
As I said, I currently slightly favor variant #1 (flexibility) but I'm also fine if the decision is
to follow variant #2 (consistency).
Am Donnerstag, 12. März 2009 schrieb Tom Hawtin:
> Alexander Potochkin wrote:
> >> Hi Florian,
> >> I'd like more consistent variant #2 because of the
> >> javax.swing.ComboBoxModel#setSelectedItem() method prevents to use
> >> construction like "<? extends E>" in the JComboBox class (as you
> >> noticed before)...
> > I second Pavel, "<? extends E>" doesn't work well for getters/setters
> > #2 is preferable
> Remember Josh Bloch's PECS: Producers Extends; Consumers Super.
> A model is both a producer and a consumer, so we want <? extends E super
> E>, i.e. <E>.
More information about the swing-dev