2003-05-22

More on DF...

Simon and Sam both responed with solid reasons why DF is a good thing.

Thinking about the .NET philosophy a little more and how it should lessen the burden on the programmer; who should be responsible for disposing of resources like file handles and sockets and when? Perhaps the compiler or the GC at runtime doesn't know when it's best?

Personally, I like the "explicitness == goodness" philosophy....right here on line 133 we are closing this file.

Thanks Simon & Sam =)

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.

2003-05-20

Using .ID to solve my SetFocus problem.

Yesterday I blogged about a problem I was having using .ClientID.

Dan replied with a few comments that sparked a set of new ideas.

In my CreateChildControls() [1] method I specified an arbitrary name for my control using the .ID property. Next I exposed my control using a readonly property [2] which I pass to the SetFocus() routine:


[1]
Protected Overrides Sub CreateChildControls()
wtCertTextBox = New TextBox()
wtCertTextBox.ID = "WtCertTextBox"
...
End Sub

[2]
Public ReadOnly Property WeightCertTextBox() As TextBox
Get
Return (wtCertTextBox)
End Get
End Property

[3]
SetFocus(LookupControl.WeightCertTextBox)

2003-05-19

SetFocus with ASP.NET ... with a little hangup

I implemented Scott Guthrie's set focus code into production code today. Works like a charm!

I did find one hang up dealing with composite controls:

I wanted to set focus to a sub control of a composite control. So I passed the reference to the function like this:


SetFocus(LookupControl1.Controls(0))


It seems like it would work but on the client's side the javascript looks like this:

<script language='javascript'>document.getElementById('LookupControl1__ctl0').focus();</script>


Yet the form's HTML looks like this:

<input name="PeelerLookupControl1:_ctl0"


it's a matter of __ vrs :_
I could hack together something to fix this but it would be best if I knew why it works that way.

Ingo on .NET Rocks!

Sehr Gut!

Ingo's on .NET Rocks! =)

http://www.franklins.net/dotnetrocks.asp

2003-05-18

Data Access Article

"I've published an article on a french site named DotNetGuru. This site is dedicated to technical articles mainly about architecture in .NET (often with comparisons with J2EE).

The subject of my article is Generic data access with ADO.NET and the Data Access Application Block. In this article I show: " [Fabrice]

Here's google's translation.

Nice article Fabrice!