On Tuesday 17 April 2007 2:52:26 pm yuping he wrote:
> Hi, I am little confused about the equals implementation in the jess. Is
> the symmetric rule violated?

In short, yes, it is. If you ask a ValueVector if it's equal to a Fact whose 
slots contain the same data as the ValueVector, it will say "yes". If you ask 
the Fact, though, it will say "no", just because the ValueVector isn't a 
Fact.

On page 30 of Josh Bloch's "Effective Java", you'll find the following 
sentence in bold at the bottom of the page: "There is simply no way to extend 
an instantiable class and add an aspect while preserving the equals 
contract". That's the difficulty that we've fallen into here: jess.Fact adds 
several data members to its parent jess.ValueVector. Both classes need 
an "equals()" method, and there's unfortunately no way to fix the problem 
except by using composition instead of inheritance -- i.e., a Fact could 
*have* a ValueVector instead of *being* a ValueVector. If Jess were being 
designed right now, that's the choice I'd make. Back when Jess was originally 
designed, and Java was brand new and being used primarily in applets, with 
tiny memory spaces, that was an unacceptable waste of an object.  So now  
this is just one of the design decisions we're stuck with.

In practice, this shouldn't matter; you should never have the occasion to have 
a heterogeneous collection of ValueVectors and Facts.

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to