Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Need clarification on Object.equals.

Reply
Thread Tools

Need clarification on Object.equals.

 
 
Jim Janney
Guest
Posts: n/a
 
      12-18-2012
http://www.velocityreviews.com/forums/(E-Mail Removed) writes:

>
> Thanks for your response,
>
> I see where the problem is. I do not directly implement equals, however Node is an extension of AbstractSet which does redefine equals. As it turns out I was in the process of rewriting Node so that it no longer extends AbsteractSet when the anomaly popped up in test code, so it is actually a mote point.


And in terms of set equality the test objects are indeed equal, since
each represents the empty set.

--
Jim Janney
 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-19-2012
On 12/18/2012 3:13 AM, (E-Mail Removed) wrote:
> In the following code Node is an abstract class and both Gate and
> Monitor are extensions of Node. a and b are distinct objects yet
> a.equals(b) is returning true.
>
> public class Foo {
> public static void main(String[] argv){
> Node a = new Gate();
> Monitor b = new Monitor();
> System.out.println(a.equals(b)); // --> prints 'true'
> }
> }
>
> The underlying production code is a bit complex to include here. My
> understanding is that equals is true if, and only if, a and b are
> exactly the same object. Here they are not even the same class.


If you post complete code illustrating the problem, then
it can be solved in a few minutes.

Our telepathic abilities are not very good.

Arne


 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-19-2012
On 12/18/2012 1:48 PM, (E-Mail Removed) wrote:
> It is complex because it is a large application. I can either post
> the several hundred lines of source or the the 6 which adequately
> illustrates the point. Node does not implement equals at all as you
> say


Those 6 lines are completely inadequate for any type of troubleshooting.

They contain zero new information compared to your description of the
problem in English.

Arne
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-19-2012
On 12/18/2012 3:17 PM, (E-Mail Removed) wrote:
> On Tuesday, December 18, 2012 2:14:58 PM UTC-6, (E-Mail Removed) wrote:
>> On Tuesday, December 18, 2012 1:01:51 PM UTC-6, David Lamb wrote:
>>> On 18/12/2012 1:48 PM, p...mail.com wrote:
>>>> On Tuesday, December 18, 2012 12:24:44 PM UTC-6, markspace wrote:
>>>>> Show us the implementation of equals() for Node (and probably Gate too,
>>>>> that version of equals() could also be borked in the example you gave)
>>>>> and we'll point out the error.
>>>> It is complex because it is a large application. I can either post the several hundred lines
>>>> of source or the the 6 which adequately illustrates the point.
>>> There's likely not much people can do to help without more context. The
>>> "6 lines" don't adequately "illustrate the point" because from them
>>> alone nobody can say for sure what your problem is. Roedy's guess might
>>> be the best advice you're going to get.

>>
>> Yes I understand that. In fact, as I pointed out in a subsequent
>> post, none of my code defines equals, Node was however extending
>> AbstractSet which does redefine it. Really All I was looking for was a
>> general direction I might look and not to burden anyone with large
>> blocks of code. Node is 212 lines, Gate is 67, Monitor another 85, none
>> of which even once mentions the word "equals"
>>
>> My issue with Roedy's response was not the helpful suggestion to
>> lookat super classes but rather that it comes off as lecturing,
>> and frankly rather condescending.

>
> Im sorry I meant markspace's responce not Roedy's


You had a problem.

A problem which is relative easy to troubleshoot with
some basic Java knowledge.

You posted the problem here with absolutely no information
to help identify the problem.

What do you expect?

We can not do anything but provide some guesses the presence of
an equals in a class or parent class - and explain some basics
about how equals work.

So stop whining and learn to post better questions.

Arne




 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-19-2012
On 12/19/2012 5:20 AM, lipska the kat wrote:
> On 19/12/12 03:16, Arne Vajh°j wrote:
>> On 12/18/2012 3:17 PM, (E-Mail Removed) wrote:

>
> [snip]
>
>>
>> So stop whining and learn to post better question.

>
> Now I'm not normally driven to using bad language but
> What the f**k is wrong with you people.
> This is Usenet, not your private little universe.


> Please think before you flame.


May I suggest that you take your own advice and
read and think before posting.

The case here is that:
* OP posted a question
* the question did not provide sufficient info
to answer it
* nobody took offense of that and OP got several
replies explained that it was difficult to say,
suggested possible reasons and explained how
equals is supposed to work
* OP characterized one of the repliers
as lecturing and condescending

I suggest that you direct you anger towards OP.

Arne



 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-19-2012
On 12/19/2012 6:22 AM, Patricia Shanahan wrote:
> On 12/19/2012 2:20 AM, lipska the kat wrote:
> ...
>> I've noticed this a lot in various newsgroups that I have been
>> frequenting of late. People who are regular contributors get the idea
>> that foo.bar.baz newsgroup is their private domain and anyone who has
>> the temerity to post a question that doesn't meet their exacting
>> standards get flamed and scolded and told to stop whining.
>>
>> I get told off but I have the skin of a Rhino and none of you silly
>> little jibes affect me or my life in any way whatsoever. Not everyone is
>> so unaffected.

> ...
>
> I strongly agree with this, except I would have preferred "Some people
> who are regular contributors ...".


Do you agree that it is acceptable behavior calling a named
replier lecturing and condescending due to this post:

<quote>
This is a red flag. The code should not be so complex that you can't
show us what is really going on. If it *is* too complex, then likely
the issue is the complexity itself.

However, I think Roedy zeroed in on the most likely cause. Your
abstract class, Node (or some superclass), implements equals()
*incorrectly* and is returning true when it should not. Probably Node()
should not implement equals() at all.

Show us the implementation of equals() for Node (and probably Gate too,
that version of equals() could also be borked in the example you gave)
and we'll point out the error.
<quote>

??

Arne


 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-19-2012
On 12/19/2012 9:07 AM, Arne Vajh°j wrote:
> On 12/19/2012 6:22 AM, Patricia Shanahan wrote:
>> On 12/19/2012 2:20 AM, lipska the kat wrote:
>> ...
>>> I've noticed this a lot in various newsgroups that I have been
>>> frequenting of late. People who are regular contributors get the idea
>>> that foo.bar.baz newsgroup is their private domain and anyone who has
>>> the temerity to post a question that doesn't meet their exacting
>>> standards get flamed and scolded and told to stop whining.
>>>
>>> I get told off but I have the skin of a Rhino and none of you silly
>>> little jibes affect me or my life in any way whatsoever. Not everyone is
>>> so unaffected.

>> ...
>>
>> I strongly agree with this, except I would have preferred "Some people
>> who are regular contributors ...".

>
> Do you agree that it is acceptable behavior calling a named
> replier lecturing and condescending due to this post:
>
> <quote>
> This is a red flag. The code should not be so complex that you can't
> show us what is really going on. If it *is* too complex, then likely
> the issue is the complexity itself.
>
> However, I think Roedy zeroed in on the most likely cause. Your
> abstract class, Node (or some superclass), implements equals()
> *incorrectly* and is returning true when it should not. Probably Node()
> should not implement equals() at all.
>
> Show us the implementation of equals() for Node (and probably Gate too,
> that version of equals() could also be borked in the example you gave)
> and we'll point out the error.
> <quote>
>
> ??


My point is that while newbies do have a "allowed to post
stupid questions" card, then they do not have a "allowed
to insult others without being criticized for it" card.

Arne


 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-19-2012
On 12/19/2012 9:36 AM, lipska the kat wrote:
> On 19/12/12 14:09, Arne Vajh°j wrote:
>> On 12/19/2012 9:07 AM, Arne Vajh°j wrote:
>>> On 12/19/2012 6:22 AM, Patricia Shanahan wrote:
>>>> On 12/19/2012 2:20 AM, lipska the kat wrote:
>>>> ...

>
> [snip]
>
>>
>> My point is that while newbies do have a "allowed to post
>> stupid questions" card, then they do not have a "allowed
>> to insult others without being criticized for it" card.


> Your arrogance is almost beyond belief. Listen to yourself
> You really do think that you are in some way qualified to pass judgment
> on what is a stupid question and what isn't.


Congratulations you completely missed the point.

> This is USENET, you don't own it, you don't have the right to tell
> people what they can and cannot post,


And you are trying to do what?

Arne

 
Reply With Quote
 
Joshua Cranmer
Guest
Posts: n/a
 
      12-19-2012
On 12/19/2012 8:36 AM, lipska the kat wrote:
> On 19/12/12 14:09, Arne Vajh├Şj wrote:
>> On 12/19/2012 9:07 AM, Arne Vajh├Şj wrote:
>>> On 12/19/2012 6:22 AM, Patricia Shanahan wrote:
>>>> On 12/19/2012 2:20 AM, lipska the kat wrote:
>>>> ...

>
> [snip]
>
>>
>> My point is that while newbies do have a "allowed to post
>> stupid questions" card,

>
> Your arrogance is almost beyond belief. Listen to yourself
> You really do think that you are in some way qualified to pass judgment
> on what is a stupid question and what isn't.


I would suggest that you finish reading entire posts before starting
yelling matches, for if you had finished the sentence (assuming basic
fluency in reading comprehension), you would have learned that Arne was
opining that the criterion for what should be considered socially
acceptable by this newsgroup isn't the quality of the question but
rather by whether or not it is insulting. Also note that there was in no
way any attempt to delineate specifically what class of questions
corresponds to "stupid questions," which is apt because the entire point
of the post was to postulate the nonimportance of such a class.

Unless you were trying to be ironic.

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
 
Reply With Quote
 
Lars Enderin
Guest
Posts: n/a
 
      12-19-2012
2012-12-19 16:05, lipska the kat skrev:
> On 19/12/12 14:42, Arne Vajh°j wrote:
>> On 12/19/2012 9:36 AM, lipska the kat wrote:
>>> On 19/12/12 14:09, Arne Vajh°j wrote:
>>>> On 12/19/2012 9:07 AM, Arne Vajh°j wrote:
>>>>> On 12/19/2012 6:22 AM, Patricia Shanahan wrote:
>>>>>> On 12/19/2012 2:20 AM, lipska the kat wrote:
>>>>>> ...
>>>
>>> [snip]
>>>
>>>>
>>>> My point is that while newbies do have a "allowed to post
>>>> stupid questions" card, then they do not have a "allowed
>>>> to insult others without being criticized for it" card.

>>
>>> Your arrogance is almost beyond belief. Listen to yourself
>>> You really do think that you are in some way qualified to pass judgment
>>> on what is a stupid question and what isn't.

>>
>> Congratulations you completely missed the point.

>
> No I didn't and I quote
>
> "My point is that while newbies do have a "allowed to post
> stupid questions" card"
>
> Who 'allows' them to post stupid questions.
> You ?
>
> Who decides who is a newbie
> You ?
>
> Who decides it is a stupid question
> You ?
>
> And before you use the 'community' card
>
> Who made you the spokesperson
> You ?
>
> Well ?


You're overreacting, in a big way (and there should be no space before
?). You completely missed the spirit (and point) of Arne's response(s).



--
Lars Enderin
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need clarification on a function declaration wizwx C Programming 9 02-13-2007 03:19 PM
need clarification with import statements Tool69 Python 2 12-15-2006 11:56 AM
Need clarification on 'typedef' keyword Krishna C++ 5 04-01-2005 05:21 PM
Need clarification on asp_wp.exe,aspnet_wp.exe and aspnet_isapi.dll prem ASP .Net 1 11-03-2004 05:32 AM
Need some clarification and/or help with java NIO sockets HDSkiFreak Java 2 05-11-2004 01:48 PM



Advertisments