Skip to main content



      Home
Home » Eclipse Projects » GEF » Shouldn't getDragTracker() return always the same instance of a DragTracker?
Shouldn't getDragTracker() return always the same instance of a DragTracker? [message #24963] Mon, 07 October 2002 10:48 Go to next message
Eclipse UserFriend
Hello,

I am a bit concerned by the implementation of the getDragTracker() method in
class org.eclipse.gef.examples.logicdesigner.edit.LogicDiagramEdit Part of
the Logical Diagram Editor example (latest version, i.e., 20020821).

Indeed, this method implementation:

public DragTracker getDragTracker(Request req){
return new MarqueeDragTracker();
}

returns a new object each time it is called.... and it is called each time a
drag selection is began.
Shouldn't it be better to use a singleton to create once a
MarqueeDragTracker() and always return this instance?
I made this modification to my code which run fine, except that it does no
longuer perform so many object creations...

Is this okay from GEF interfaces / internal flow of calls, or am I taking a
risk?

Best regards,

Alex
Re: Shouldn't getDragTracker() return always the same instance of a DragTracker? [message #25120 is a reply to message #24963] Mon, 07 October 2002 14:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

I don't see any reason to cache the tool. The MouseEvent that was the cause
of the marquee tool being activated is also a new Object. There are
probably several other new objects created then too, and none of them are
expensive.

"Alexandre Vermeerbergen" <ave@ds-fr.com> wrote in message
news:ans5g6$mer$1@rogue.oti.com...
> Hello,
>
> I am a bit concerned by the implementation of the getDragTracker() method
in
> class org.eclipse.gef.examples.logicdesigner.edit.LogicDiagramEdit Part of
> the Logical Diagram Editor example (latest version, i.e., 20020821).
>
> Indeed, this method implementation:
>
> public DragTracker getDragTracker(Request req){
> return new MarqueeDragTracker();
> }
>
> returns a new object each time it is called.... and it is called each time
a
> drag selection is began.
> Shouldn't it be better to use a singleton to create once a
> MarqueeDragTracker() and always return this instance?
> I made this modification to my code which run fine, except that it does no
> longuer perform so many object creations...
>
> Is this okay from GEF interfaces / internal flow of calls, or am I taking
a
> risk?
>
> Best regards,
>
> Alex
>
>
>
Re: Shouldn't getDragTracker() return always the same instance of a DragTracker? [message #25486 is a reply to message #25120] Tue, 08 October 2002 08:53 Go to previous message
Eclipse UserFriend
"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:ansi5p$vkr$1@rogue.oti.com...
> I don't see any reason to cache the tool. The MouseEvent that was the
cause
> of the marquee tool being activated is also a new Object. There are
> probably several other new objects created then too, and none of them are
> expensive.

Alright, so you mean my optimization is not false, but it is of little
value, right?

At least if it's not breaking anything and saves a little bit of garbage
collector's work...
So I can do it anyway, I guess.


Alex.
Previous Topic:Hello Gef #1 : a first tutorial example (comments welcome)
Next Topic:Create a Diamond Class using Polygon Class in GEF
Goto Forum:
  


Current Time: Mon Apr 28 02:49:28 EDT 2025

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

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

Back to the top