Skip to main content



      Home
Home » Eclipse Projects » GEF » model objects changing their identity
model objects changing their identity [message #208403] Thu, 02 February 2006 04:38 Go to next message
Eclipse UserFriend
Originally posted by: christian.sell.netcologne.de

Hello all,

in our GEF applications the model objects override the equals() and
hashCode() methods to compute them based on certain object attributes.
GEF maintains an EditPart registry which uses these objects as keys,
which becomes a problem if the identity attributes of the model objects
change.

My question: is there any recommended practice for cases like the one
above?

thanks,
Christian
Re: model objects changing their identity [message #208456 is a reply to message #208403] Thu, 02 February 2006 15:55 Go to previous messageGo to next message
Eclipse UserFriend
I would expect that you would have to remove and then re-add the model
objects from the registry under these conditions.

If your EditPart is able to identify when this happens, it could force a
refreshChildren on it's parent to add / remove itself:

i.e.
EditPart parent = getParent();
parent removeChild(this);
parent refreshChildren();

-Steve

"Christian Sell" <christian.sell@netcologne.de> wrote in message
news:drsju9$g13$1@utils.eclipse.org...
> Hello all,
>
> in our GEF applications the model objects override the equals() and
> hashCode() methods to compute them based on certain object attributes.
> GEF maintains an EditPart registry which uses these objects as keys,
> which becomes a problem if the identity attributes of the model objects
> change.
>
> My question: is there any recommended practice for cases like the one
> above?
>
> thanks,
> Christian
Re: model objects changing their identity [message #208464 is a reply to message #208456] Thu, 02 February 2006 17:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: christian.sell.netcologne.de

thats what I concluded, too. I guess the real lesson is that the model
should not override the concept of equality/identity at all.

christian

Steven Shaw wrote:
> I would expect that you would have to remove and then re-add the model
> objects from the registry under these conditions.
>
> If your EditPart is able to identify when this happens, it could force a
> refreshChildren on it's parent to add / remove itself:
>
> i.e.
> EditPart parent = getParent();
> parent removeChild(this);
> parent refreshChildren();
>
> -Steve
>
> "Christian Sell" <christian.sell@netcologne.de> wrote in message
> news:drsju9$g13$1@utils.eclipse.org...
>> Hello all,
>>
>> in our GEF applications the model objects override the equals() and
>> hashCode() methods to compute them based on certain object attributes.
>> GEF maintains an EditPart registry which uses these objects as keys,
>> which becomes a problem if the identity attributes of the model objects
>> change.
>>
>> My question: is there any recommended practice for cases like the one
>> above?
>>
>> thanks,
>> Christian
>
>
Re: model objects changing their identity [message #208736 is a reply to message #208464] Wed, 08 February 2006 05:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ingo.koch[nospam].sap.com

Hi Christian,

perhaps you should re-think your equals()-design.
Are two objects of your model, which are equal, really identical, one and
the same?
If not, you should not override the equals-method but test the "equality" of
your models in another method.

Regards, Ingo



"Christian Sell" <christian.sell@netcologne.de> wrote in message
news:dru17a$cbc$1@utils.eclipse.org...
> thats what I concluded, too. I guess the real lesson is that the model
> should not override the concept of equality/identity at all.
>
> christian
>
> Steven Shaw wrote:
> > I would expect that you would have to remove and then re-add the model
> > objects from the registry under these conditions.
> >
> > If your EditPart is able to identify when this happens, it could force a
> > refreshChildren on it's parent to add / remove itself:
> >
> > i.e.
> > EditPart parent = getParent();
> > parent removeChild(this);
> > parent refreshChildren();
> >
> > -Steve
> >
> > "Christian Sell" <christian.sell@netcologne.de> wrote in message
> > news:drsju9$g13$1@utils.eclipse.org...
> >> Hello all,
> >>
> >> in our GEF applications the model objects override the equals() and
> >> hashCode() methods to compute them based on certain object attributes.
> >> GEF maintains an EditPart registry which uses these objects as keys,
> >> which becomes a problem if the identity attributes of the model objects
> >> change.
> >>
> >> My question: is there any recommended practice for cases like the one
> >> above?
> >>
> >> thanks,
> >> Christian
> >
> >
Re: model objects changing their identity [message #208768 is a reply to message #208736] Wed, 08 February 2006 08:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: christian.sell.netcologne.de

sure, I agree. Maybe overriding equals() and hashCode() is something one
should be more wary of doing in general. I went ahead and removed the
methods, and replaced them with an explicit comparison method wherever
needed - as you suggest.

One intention with this post was to make this requirement public.

-C

Ingo Koch wrote:
> Hi Christian,
>
> perhaps you should re-think your equals()-design.
> Are two objects of your model, which are equal, really identical, one and
> the same?
> If not, you should not override the equals-method but test the "equality" of
> your models in another method.
>
> Regards, Ingo
>
>
>
> "Christian Sell" <christian.sell@netcologne.de> wrote in message
> news:dru17a$cbc$1@utils.eclipse.org...
>> thats what I concluded, too. I guess the real lesson is that the model
>> should not override the concept of equality/identity at all.
>>
>> christian
>>
>> Steven Shaw wrote:
>>> I would expect that you would have to remove and then re-add the model
>>> objects from the registry under these conditions.
>>>
>>> If your EditPart is able to identify when this happens, it could force a
>>> refreshChildren on it's parent to add / remove itself:
>>>
>>> i.e.
>>> EditPart parent = getParent();
>>> parent removeChild(this);
>>> parent refreshChildren();
>>>
>>> -Steve
>>>
>>> "Christian Sell" <christian.sell@netcologne.de> wrote in message
>>> news:drsju9$g13$1@utils.eclipse.org...
>>>> Hello all,
>>>>
>>>> in our GEF applications the model objects override the equals() and
>>>> hashCode() methods to compute them based on certain object attributes.
>>>> GEF maintains an EditPart registry which uses these objects as keys,
>>>> which becomes a problem if the identity attributes of the model objects
>>>> change.
>>>>
>>>> My question: is there any recommended practice for cases like the one
>>>> above?
>>>>
>>>> thanks,
>>>> Christian
>>>
>
>
Re: model objects changing their identity [message #208798 is a reply to message #208768] Wed, 08 February 2006 12:51 Go to previous message
Eclipse UserFriend
Originally posted by: christian.sell.netcologne.de

in fact, I would generalize my rule like this:

overriding equals() and hashCode() based on mutable attributes (i.e.
ones that are not declared final) is *always* questionable

-christian

Christian Sell wrote:
> sure, I agree. Maybe overriding equals() and hashCode() is something one
> should be more wary of doing in general. I went ahead and removed the
> methods, and replaced them with an explicit comparison method wherever
> needed - as you suggest.
>
> One intention with this post was to make this requirement public.
>
> -C
>
> Ingo Koch wrote:
>> Hi Christian,
>>
>> perhaps you should re-think your equals()-design.
>> Are two objects of your model, which are equal, really identical, one and
>> the same?
>> If not, you should not override the equals-method but test the "equality" of
>> your models in another method.
>>
>> Regards, Ingo
>>
>>
>>
>> "Christian Sell" <christian.sell@netcologne.de> wrote in message
>> news:dru17a$cbc$1@utils.eclipse.org...
>>> thats what I concluded, too. I guess the real lesson is that the model
>>> should not override the concept of equality/identity at all.
>>>
>>> christian
>>>
>>> Steven Shaw wrote:
>>>> I would expect that you would have to remove and then re-add the model
>>>> objects from the registry under these conditions.
>>>>
>>>> If your EditPart is able to identify when this happens, it could force a
>>>> refreshChildren on it's parent to add / remove itself:
>>>>
>>>> i.e.
>>>> EditPart parent = getParent();
>>>> parent removeChild(this);
>>>> parent refreshChildren();
>>>>
>>>> -Steve
>>>>
>>>> "Christian Sell" <christian.sell@netcologne.de> wrote in message
>>>> news:drsju9$g13$1@utils.eclipse.org...
>>>>> Hello all,
>>>>>
>>>>> in our GEF applications the model objects override the equals() and
>>>>> hashCode() methods to compute them based on certain object attributes.
>>>>> GEF maintains an EditPart registry which uses these objects as keys,
>>>>> which becomes a problem if the identity attributes of the model objects
>>>>> change.
>>>>>
>>>>> My question: is there any recommended practice for cases like the one
>>>>> above?
>>>>>
>>>>> thanks,
>>>>> Christian
>>
Previous Topic:How to set Text in a Shape ?
Next Topic:Hide tooltip figures manually
Goto Forum:
  


Current Time: Wed Jul 23 11:31:33 EDT 2025

Powered by FUDForum. Page generated in 0.11768 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top