2 clarifications are in order.

First of all, A ColoredList is NOT List<Color> - it's a List<T> where,
in addition to having a bunch of Ts in it (or no Ts), the list has a
color. 1 Color. It's not stored in the list. It's extra. The list has
a setColor(Color x) and getColor() method which are entirely
independent of get(int idx), add(), etcetera.

And, Vince: I'm not sure we're disagreeing here - I was trying to say
that having an empty red list equal an empty blue list is a very bad
idea, and you seem to be saying the same. However bad the idea may
seem, if you were to write an actual ColoredList implementation that
implements "java.util.List", you are FORCED to make an empty blue list
equal an empty red list. Your hands are tied by the contract, there is
no way out. The idea stated in my OP, if List/AbstractList was
programmed with that from the start, would have untied your hands.

Liam: Yes, this conversation means something in practice. When writing
a non-final class, you never know what's going to happen down the
line. Also, this idea or some other is going to show up in lombok, and
via lombok, in lots of classes.

On Oct 17, 12:31 pm, "Vince O'Sullivan" <[email protected]> wrote:
> On Oct 17, 7:06 am, Reinier Zwitserloot <[email protected]> wrote:
>
> > ...but if you ever create a ColoredList
> > class, which gives all lists color, you MUST write its equals method
> > so that an empty red list is equal to an empty blue list, even though
> > that seems ridiculous.
>
> Not so ridiculous.  I think that the basic premise that the two empty
> lists must be equal is wrong.  The reason being that you can't always
> substitute an empty red list for an empty blue list.  Try adding a red
> item to a blue list and you'll soon find that the empty lists weren't
> so equal after all.
>
> V.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to