On Fri, 2003-01-31 at 10:33, Rob van Maris wrote:
> <Pierre van Rooden:>
> > MyImgBuilder.extends(ImagesBuilder) || 
> > MyImgBuilder.equals(ImagesBuilder)
> 
> I think this is even better (both simpler and clearer):
> builder1 == builder2 || builder1.extends(builder2)

When comparing non-primitive datatypes in Java, I prefer an '.equals()'
method over a normal equality. This is because for non-primitive
datatypes, the '==' will only return true if the two variables point to
the same object. This may be the case now, but we do not know if it will
be in the future: the test specified above is tied to a very specific
implementation of builders. 

A small quote from the Java Language Specification:

-----
While == may be used to compare references of type String, such an
equality test determines whether or not the two operands refer to the
same String object. The result is false if the operands are distinct
String objects, even if they contain the same sequence of characters.
The contents of two strings s and t can be tested for equality by the
method invocation s.equals(t).
-----

I would vote for a 'builder.equals(builder)' method.

Johannes
-- 
[EMAIL PROTECTED]      | It is always possible to aglutenate multiple
[EMAIL PROTECTED]   | seperate problems into a single complex inter-
[EMAIL PROTECTED] | dependent solution. In most cases this is a
PGP ID: 0xFED127BD     | bad idea. (RFC 1925, Truth 5)


Reply via email to