> 1. We should rename the DBConnection class to DBConnectionFactory. I
> have often wondered what a factory is in this sense, could you
> elaborate?

charles answered this very well :)

> 2. Adding a finalize() method in the external class 
> --> wouldn't that nullify the DataSource before we are 
> finished with it?
> --> isn't that doubling up with the destroy() method?
> --> how much better would it be to nullify the DataSource in a
> finalize() method, a destroy() method or both?

overriding the Object.finalize method ensures that the JRE will perform the statements 
contained within it. You don't actually "need" to do this if you think the JRE will 
spot when your objects are ready for GC, but sometimes it's good to explicitly do it. 
I normally write an interface called DisposableObject that defines 1 method

public void destroy()

I override finalize to just call this method. That way, either an external call OR a 
JRE call will get to destroy() to clean up any internal resources for sure.

finalize will only be called when all references to the factory are lost and therefore 
the JRE starts to GC it. Yes it would double up if you have a destroy method but see 
my last commment on linking the two.

> 3. I'd like to find out more about 'adding a static reference 
> to itself
> and adding a static method called getInstance()' 
> --> how much more efficient would that be?
> --> how do I implement that?
> </question>

here's a good tutorial on Singletons

http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html

hope this helps, Allistair


<FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> 
-------------------------------------------------------
QAS Ltd.
Developers of QuickAddress Software
<a href="http://www.qas.com";>www.qas.com</a>
Registered in England: No 2582055
Registered in Australia: No 082 851 474
-------------------------------------------------------
</FONT>


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

Reply via email to