473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Why use a CollectionBase class here vs dataset or dataview?

jc
RE: Why use a CollectionBase class here vs dataset or dataview?

I'm looking at some vb.net 2005 code that was generated from a
homegrown Codesmith Template that generate all of the retreival and
update code for typical vb.net / asp.net data maintenance
applications. For some reason they have two class files for each
table, one is a collection class. Oddly both have the same properties
for each table column duplicated.. a lot of duplicate code and I'm
trying to understand why. Also, I'm trying to explain why the use of a
collection class anyways.

Perhaps the motivation was a more pure OOP approach, or perhaps
eventual scalability.

1. why the two classes?

Imports System.Configuration.ConfigurationManager
Namespace WH
Public Class Collaborator
Private m_ColId As Integer
Private m_Lastname As String
Get
Return m_ColId
End Get
Set(ByVal value As Integer)
m_ColId = value
End Set
End Property

and the other like this:

Namespace WH
Public Class colCollaborator
Inherits System.Collections.CollectionBase
#Region "List Data Structure"
Public Structure s_Collaborator
Private m_Result As String
Public Property ColId() As Integer
Get
Return m_ColId
End Get
Set(ByVal value As Integer)
m_ColId = value
End Set
End Property
Can't they be combined?

2. Sorry for the potentially noob OOP question, but why even use a
collection class? Any way to have a class that stores a dataset or a
dataview? And if not and a valid reason for the collection class, why
not one class file and one set of properties? The collection class
uses a reader to load the collection list..

Me.List.Add(FromDataReader(oRdr, blnAdd0Index))

Thanks for any help or information!
Jun 27 '08 #1
1 2566
jc,

One of the basics of OOP are the enumerable collections.

Look at this more simpliefied schema
Collection A holds a reference to another collection B which has a
Collection of
C. C is a simple item that only holds a back reference to B where it is in.
As you fill one C in table B you see in the debuger in quickwatch something
like this.

A
.B
C
B
C
B
etc. and that goes endless on, I did not try to show
this exact because as I see this in quickwatch I too have always to follow
the lines.

This is probably the reason that some people think that a dataset is a very
memory consuming thing, while it is only something as I tried to explain
above. In this sample there is only one item that holds a reference back to
B and is in that B collection, which is again referenced by A in a
collection.

A dataset is something that holds references to
-collections of relations which has a reference back to the dataset
-collections of tables which has a reference back to the dataset
-some name giving properties
-the collection of tables holds references to
-collections of columnames which have a reference back to the table
-collections of rows which have a reference back to the table
-some properties including the dataview which
has a reference back to the datatable
-the rows holds references to items which are in
fact the true object which holds the data.

In my idea it is because of that people don't understand this that they have
made all kind of solutiong so make by them so called lightweight
datacollection. In fact those are probably mostly consuming much more
resources.

Cor


"jc" <wi*****@noclient.netschreef in bericht
news:83**********************************@m45g2000 hsb.googlegroups.com...
RE: Why use a CollectionBase class here vs dataset or dataview?

I'm looking at some vb.net 2005 code that was generated from a
homegrown Codesmith Template that generate all of the retreival and
update code for typical vb.net / asp.net data maintenance
applications. For some reason they have two class files for each
table, one is a collection class. Oddly both have the same properties
for each table column duplicated.. a lot of duplicate code and I'm
trying to understand why. Also, I'm trying to explain why the use of a
collection class anyways.

Perhaps the motivation was a more pure OOP approach, or perhaps
eventual scalability.

1. why the two classes?

Imports System.Configuration.ConfigurationManager
Namespace WH
Public Class Collaborator
Private m_ColId As Integer
Private m_Lastname As String
Get
Return m_ColId
End Get
Set(ByVal value As Integer)
m_ColId = value
End Set
End Property

and the other like this:

Namespace WH
Public Class colCollaborator
Inherits System.Collections.CollectionBase
#Region "List Data Structure"
Public Structure s_Collaborator
Private m_Result As String
Public Property ColId() As Integer
Get
Return m_ColId
End Get
Set(ByVal value As Integer)
m_ColId = value
End Set
End Property
Can't they be combined?

2. Sorry for the potentially noob OOP question, but why even use a
collection class? Any way to have a class that stores a dataset or a
dataview? And if not and a valid reason for the collection class, why
not one class file and one set of properties? The collection class
uses a reader to load the collection list..

Me.List.Add(FromDataReader(oRdr, blnAdd0Index))

Thanks for any help or information!
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Arthur Dzhelali | last post by:
I according to MSDN dataview and dataset are thread safe for read operations, but we run into this scenario. I just would like to see some comments on it. Aplication written in VB.NET it is an...
4
by: Siu | last post by:
Hi, I've written a class which inheritates from the CollectionBase class public class MyClass : CollectionBase { } An object istantiated from MyClass can be transformed in a DataSet? does...
2
by: Dennis | last post by:
Hi, I am hoping I can get some help with a small problem I have run into using C#. U have an XML file that I load into a Dataset and then display this in a Datagrid. No problems doing this at all....
1
by: Kyle Novak | last post by:
I have a question about strongly typed objects when looping through a collection based on the CollectionBase object and using a For..Each loop. I have 2 objects: -Invoice: Holds all properties...
2
by: Samuel R. Neff | last post by:
What's the advantage of inheriting from CollectionBase as opposed to just implementing IList? It seems that it saves you from having to implement a few properties (Clear, CopyTo, Count,...
0
by: Bob Davies | last post by:
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within a dataset, however upon attempting to create...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
6
by: Joseph I. Ceasar | last post by:
I have an ASP .Net 2.0 site that I am working on. It has a master page and a content page. I also created a separate class module that returns a DataSet to feed my GridView. So far, so good. ...
11
by: Sid Price | last post by:
I have Dataset that I need to filter into another Dataset for display and I can not find out how to do this. I have found methods for copying a Dataset but I can not see how to filter the rows...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.