Frank Schönheit - Sun Microsystems Germany escribió:
Hi Ariel,

By the way, a doubt: should we dispose() the dialog after execute() returns?

You won't find a "dispose" at this particular dialog implementation :)

I "always" do it with other XExecutableDialog's (as the GUI chap. says to always dispose() the FilePicker).

"dispose" has a good and a bad side: For one, it allows explicit
resource control: As soon as you call it, the implementation will (read:
is required to) free all allocated resources (of whatever kind). This is
especially useful when working with Java, since due to Java's memory
management, you cannot otherwise control the life time. (In C++ you just
release the last reference to the object, and it will die. In Java, the
last reference is released in the next garbage collection after your
code released the object.)

On the other hand, the necessity to dispose cares the risk of forgetting
it. If implementations rely on somebody disposing them (and sometimes
this can hardly be avoided), then as soon as a client forgets the
disposal, the resources are never freed.


That said, in the case of the wizard, I'd say it could use a disposal
mechanism - when called, it would free the connections. Sadly, this
requires expensive changes in some generic base class, so I discarded
this idea a while ago. For the moment, at least.

And another one: I always remove everything I add (like listeners), but: is it really needed? or when the object gets disposed (by me or others) all references get released? Applied to this case: should we remove the XCopyTableListener after execute() + then dispose()?

Normally it is not necessary. Every dispose implementation I know will
also release all listeners. If there is no "dispose", as in our case,
then the object will release the listeners as soon as itself dies.

However, removing listeners can sometimes help avoiding cyclic
references (A holds a reference to B, and B holds a reference to A, or
with even more involved components than just A and B). Cyclic references
are a major reason for resource leaks, since C++, in opposite to Java,
does not automatically detect and break them. In theory, they can always
be avoided, in practice, this is tremendously expensive sometimes.

So, removing your listeners when they're not needed anymore might in
fact be a good idea, I would consider it good style.

Ciao
Frank


Thanks for the advice (== a "lesson")!

Bye
Ariel



--
Ariel Constenla-Haile
La Plata, Argentina

[EMAIL PROTECTED]
[EMAIL PROTECTED]

http://www.arielconstenlahaile.com.ar/ooo/



"Aus der Kriegsschule des Lebens
                - Was mich nicht umbringt,
        macht mich härter."
                Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to