Generated Code Confusion - Structure? Collection Class?

W

wildman

Looking at an old web application.A popular .net code generation tool
was apparently used to generated a Data and/or Business Layer of
classes for the ap.

For whatever reason, it seems to have generated two VB class per
table, one with the table name and the other with the prefix Col (as
in collection I presume).

When we look at the ColTBL.vb source for example we see something
like this:

Public Class colTBL
Inherits System.Collections.CollectionBase
#Region "List Data Structure"
Public Structure s_TBL
Private m_F1Key As Integer
Private m_F2Data As String

Public Property F1Key() As Integer
Get
Return m_UMKey
End Get

Set(ByVal Value As Integer)
m_F1Key = Value
End Set
End Property


I'm a bit perplexed, and likely some OOP learning curve thingie. But
Another developer said this class is a collection class. Is that an
accurate term? Can anybody elaborate on how such as class might be
used?

The other class looks more familiar to me, having all the properties
required store all entries of the table and a method called find that
does set all the properties. That class TBL.vb source looks like this:


Public Class TBL
Private m_F1Key As Integer
Private m_F2Data As String
Public Property F1Key() As Integer
Get
Return m_F1Key
End Get
Set(ByVal value As Integer)
m_F1Key = value
End Set
End Property

Since there appears to be very limited use of the ColTBL class, can
somebody clue in me in on what some uses of such a class might be?

Thank you for any help or information!
 
C

Cor Ligthert[MVP]

Wildman,

Your second class is in fact just a single Property in a Class that holds
some integer data for the F1 key, the member
"Private m_F2Data As String" does nothing in that. It does as much as a
simple Integer.

You can do with that
dim F1KeyData as New TBL
however it is the same as
dim F1KeyData as Integer

The first one seems me a try to create an user collection typed based on the
Collectionbase class (an must inherit class).
The Collection base information is in my idea very clear on MSDN

http://msdn2.microsoft.com/en-us/library/system.collections.collectionbase.aspx

Cor
 

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

Top