2003-05-22

Deterministic Finalization

I don't quite get what all the fuss is about with not having DF in managed code.
I mean if you can do this:


void fooplusplus()
{
... // do stuff
~someobject();
}


why would this be any worse?:


void foosharp()
{
... // do stuff
someobject.Dispose();
}


Besides from having to implement the IDisposable design pattern and fleshing out the Finalize code, I don't see how it could be so bad.
Besides which of the following is worse:


void fooplusplus()
{
... // do stuff
// I forgot to do this
//~someobject();
}

void foosharp()
{
... // do stuff
// I didn't know I had to do this
// someobject.Dispose(); }



UPDATE: as I'm reading more about DF in C++ I'm seeing how it's practically used and now it makes sense. I guess I just don't see why .Dispose() is so bad.

0 Comments:

Post a Comment

<< Home