[MOBY-dev] Re: suggestions about the latest version

Paul Gordon gordonp at ucalgary.ca
Tue Apr 5 15:03:39 UTC 2005


Hi Sophie,

    I'm cc'ing the list as this may be of some interest to other Java 
developers...

Sophie Durand wrote:

> Hi,
>
> Thanks to have modified so quickly on my demand !
> I have some remarks about the lastest version:
>
> In the MobyDataSimpleInstance.java file, for the equals method, I 
> would have compared values with
> ourObject.equals(passedInObject)
> instead of comparing the references that would generally be different.
> This will use the equals method of BigInteger or BigDecimal depending 
> on the instance.

Oops, this is what I meant to do!  I even wrote that to you!  I've fixed 
this now.

> I've read the Java API for the comparable interface :
> compareTo
> Throws:
>     ClassCastException - if the specified object's type prevents it 
> from being compared to this Object.
> Probably you should throw an Exception if the given object is not a 
> MobyDataSimpleInstance.

I thought about this, but decided to allow any objects to be compared 
because I did not want to hard code in the
list of acceptable child classes.  This would mean if MobyDataX was 
added as a class, you'd have to remember to add X and other compatible 
classes to MobyDataSimple's equals() (to allow for the convenient 
comparison of java.lang.Integer and org.biomoby.shared.MobyDataInteger 
for example).  If a child class wants to enforce a class equivalency, 
they can override the equals method.  I've added the ClassCastException 
for this reason, but do not throw it in MobyDataSimpleInstance's 
method.  Luckily you can say that you throw a ClassCastException, even 
if you don't, without the compiler complaining.

>
> In MobyDataFloat.java, there seems to be a problem in the clone 
> function : it returns an instance of MobyDataInt...

Fixed...

> Sophie





More information about the MOBY-dev mailing list