Why do this?

  • Thread starter Thread starter VB Student
  • Start date Start date
V

VB Student

VS.NET's dataform wizard is a great little tool for generating code. But I
can't for the life of me, work out why it generated the following on
consequtive lines of code:

Dim my1stDS as System.Data.DataSet = new MyAssembley.MyTypedDataSet
Dim my2ndDS as MyAssembley.MyTypedDataSet = new MyAssembley.MyTypedDataSet

Can anyone here shed some light on the differences between the two lines of
code? Is there any advantage (other than brevity) of coding one over the
other?
 
VS.NET's dataform wizard is a great little tool for generating code. But I
can't for the life of me, work out why it generated the following on
consequtive lines of code:

Dim my1stDS as System.Data.DataSet = new MyAssembley.MyTypedDataSet
Dim my2ndDS as MyAssembley.MyTypedDataSet = new MyAssembley.MyTypedDataSet

The first one creates a late bound version of your typed dataset. The two
datasets are the same, but the second one (theoretically, and we've done a
few tests on this in here) would run faster, because there is no "unboxing"
to be done (as in saving an integer into an object, etc..)

Because of inheritance, you can declare it either way. Late Binding can
cause problems if you don't know what your doing and can sometimes cause
performance hits. Most times you wouldn't know.

With the early bound dataset (the second one) you don't run the risk of type
mismatches and what not, because the complier will catch at compile time if
you are trying to do something with incompatible datatypes (or assign a
field that doesn't exist, whatever, the list goes on and on). Whereas
latebound wont catch this till runtime.

Sometimes you need late bound, sometimes you need early bound. depends on
the application. Why it developed both, I don't know. I don't use the data
form wizard.

-CJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top