-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: SitaramanM
Message 2 in Discussion

Hi Anand   Guess u are in a questioning spree :) Here you go             What is the 
Difference bet obj=null and obj.dispose()          When you set the obj=-null what you 
are doing essentially is to make the obj go out of scope and making it eligible for a 
garbage collection later.  When you set it to null,  the reference is removed from the 
application roots and therefore the Garbage Collector will consider this object for 
collection.   
Dispose however is a different story altogether.  Dispose rather than a deallocator, 
is basically a best practice.  You do understand that .Net works in a GC mode Right!!! 
 Now it is possible that there could be unmanaged resources that your application 
might be using and these need to be closed disposed off explicitly,  example could 
open file handles.  Now where do you write code for closing these resources.  in C++ 
yiou would have written it in destrcutors.  As you know destructors are not there in 
.Net.  So you could write it in Finalize(However do note that Finalize is NOT the .Net 
equivalent of destructors).  The problem with finalize is that you will never know 
when it will be called.  So instead of  depending on the runtime to close such 
unmanaged resources which could happen anytime at the prerogative of GC, you would 
rather write the cleanup code in dispose and ask he consumers of the class to call it 
explicitly.  What you also typically do is that you write the cleanup code in a 
separate function , lets say cleanup() and then call this method from the both dispose 
and finalize.  This way,  if the consumer of the class is decent enough to call the 
dispose, then the cleanup will happen  immdtly,  if the consumer does not call dispose 
then atleast finlize will do the cleanup( though it is not typically recommended to 
perform time/resouirce intensive operations in finalize).  One step furthur, you can 
maintain flags in finalize and call he cleanup() function only if the dispose has not 
already called it).  Two steps furthus, taking a leaf from Roshan's proprietary(had to 
lookup word for the spelling :) ) secrets(exposed, thanx to pandu),  what you can also 
do is to log the cleanup operations in finalize to check which developers had not 
called dispose(thts a good one rosh!!!)
         Apart from Overloading and overridding how can we acheive Polymorhism using 
interface and abstract class.      Apart from abstract/interfaces, One more exhibition 
of polymorphism is the Generics concept in C# 2.0 specification. It is called 
Parametricized polymorphism.  Lookup the articles on Generics on the net.  Btw one 
point to note,  Overriding happens only in the case of abstract class.  In the case of 
Interfaces it is not overriding rather it is implementation of the function.  Though 
there could be a lot of confusion over the diff btwn Interface v/s abstract class,  
the standard is that an interface is a basically a contract and the implementation is 
done in the classes that implement the interface. So i dont think it is right to call 
a method implementation of a interface as overriding!!!!        How data will be 
passed to the remote Object.          Two options By Value or By Ref.  if you want By 
Value, you go for serialization.  Serialization could be Default Serialization that is 
by decorating with the SerializableAttribute or it could b Custom Serialization that 
is by implementing the ISerializable Interface.  If you want ByRef then go for 
inheriting the MarshalByRefObject.   Such objects could be either Server 
Activated(SAO) ot Client Activated(CAO).  As far as the object formatting goes, in the 
case of both ByVal(serialized) and ByRef(MarshalByRefObject), you can use either the 
BinaryFormatter or the SoapFormatter.    How to do optimistic and pesimistic 
conditions in ADO.NET      Check out the MSDN.  has loads of material       hth 
regards,   sr

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to