473,706 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Collection object: Use CollectionBase, Generics, or DataSet

_DS
I need to create arrays of a custom data type (which is composed of
various strings, ints, the usual). The original was built using
CollectionBase. I was thinking about redesigning to use generics, but
I realized that DataSets may also work here.

I do need to display and edit lists of the items at various places.
In the previous version I used a custom ListView for most display
purposes.

Given that DataSets in VS2005 have so many extended features,
including integration with DataViews, etc., is there any reason not to
go this route? What are the disadvantages? Storage overhead? Access
speed?
Jan 27 '06 #1
4 3459
Hi,

"_DS" <_D*@Nospamform e.com> wrote in message
news:7t******** *************** *********@4ax.c om...
I need to create arrays of a custom data type (which is composed of
various strings, ints, the usual). The original was built using
CollectionBase. I was thinking about redesigning to use generics, but
I realized that DataSets may also work here.
If it's working fine, I usually prefer do not change it
I do need to display and edit lists of the items at various places.
In the previous version I used a custom ListView for most display
purposes.
You can do this whatever route you go
Given that DataSets in VS2005 have so many extended features,
including integration with DataViews, etc., is there any reason not to
go this route? What are the disadvantages? Storage overhead? Access
speed?


The dataset would be the last option for me, you won't be using the most
useful features of it, like relationships, etc, it would also dilute the
concept of a type that (hopefuly) you have rignt now.

A generic collection works like a strong typed collection in most of the
cases, one of the motives to introduce genercs was to not have to implement
almost the same code each time you want a strong typed collection.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 27 '06 #2
For what its worth, I agree with Ignacio. I wouldn't use DataSets either. I
refer to the DataSet as the Anti-OOP. Or perhaps I should call it the ~OOP.

Custom collections with indexers, and all the other cool features you get
from CollectionBase are definitely the way to go for framework version 1.1
and for the same reasons plus, as Ignacio said, better code re-use, generics
in framework version 2.0.

--
Dale Preston
MCAD C#
MCSE, MCDBA
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"_DS" <_D*@Nospamform e.com> wrote in message
news:7t******** *************** *********@4ax.c om...
I need to create arrays of a custom data type (which is composed of
various strings, ints, the usual). The original was built using
CollectionBase. I was thinking about redesigning to use generics, but
I realized that DataSets may also work here.


If it's working fine, I usually prefer do not change it
I do need to display and edit lists of the items at various places.
In the previous version I used a custom ListView for most display
purposes.


You can do this whatever route you go
Given that DataSets in VS2005 have so many extended features,
including integration with DataViews, etc., is there any reason not to
go this route? What are the disadvantages? Storage overhead? Access
speed?


The dataset would be the last option for me, you won't be using the most
useful features of it, like relationships, etc, it would also dilute the
concept of a type that (hopefuly) you have rignt now.

A generic collection works like a strong typed collection in most of the
cases, one of the motives to introduce genercs was to not have to implement
almost the same code each time you want a strong typed collection.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Jan 28 '06 #3
_DS
On Fri, 27 Jan 2006 09:02:37 -0500, "Ignacio Machin \( .NET/ C# MVP
\)" <ignacio.mach in AT dot.state.fl.us > wrote:
"_DS" <_D*@Nospamform e.com> wrote in message
news:7t******* *************** **********@4ax. com...
I need to create arrays of a custom data type (which is composed of
various strings, ints, the usual). The original was built using
CollectionBase. I was thinking about redesigning to use generics, but
I realized that DataSets may also work here.


If it's working fine, I usually prefer do not change it


Thanks for your reply, Ignacio. In this case it's not a matter of "If
it's not broke." The design is still in formative stages. I need to
settle on something that will endure.
I do need to display and edit lists of the items at various places.
In the previous version I used a custom ListView for most display
purposes.


You can do this whatever route you go


Yeah, I guess so. I was wondering if any subtleties in the DataSet
(vs Collection) would lend to advantages in binding or editing. If
there is no difference, then I guess the advantage goes to the
Collection approach. It should be faster and easier on ram.

Jan 29 '06 #4
_DS
On Sat, 28 Jan 2006 12:50:27 -0800, "Dale" <da******@nospa m.nospam>
wrote:
For what its worth, I agree with Ignacio. I wouldn't use DataSets either. I
refer to the DataSet as the Anti-OOP. Or perhaps I should call it the ~OOP.
<g> Interesting comment, Dale. Are you excluding strongly typed
DataSets? (I'm guessing that you're referring to weak typing).
Custom collections with indexers, and all the other cool features you get
from CollectionBase are definitely the way to go for framework version 1.1
and for the same reasons plus, as Ignacio said, better code re-use, generics
in framework version 2.0.


I was initially thinking that there would be better binding features
with DataSets, but since I don't need relational capabilities I'll go
with CollectionBase for now. Generics later when I'm more comfortable
with them.

Jan 31 '06 #5

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

Similar topics

2
2514
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a pointer or reference to a derived type of the base class's return type. In .NET the overridden virtual function is similar, but an actual parameter of the function can be a derived reference from the base class's reference also. This dichotomy...
3
2883
by: Andrew J. Marshall | last post by:
It was SO easy in VB6. Add a few methods, set a few funky properties and *BAM*, type-safe collection class that supports the For Each...Next syntax. I've been trying to do this in VB.NET with little success. I started inherting DictionaryBase because of the Key retrieval ability, but my code bombed on the For Each line because I had Option Strict On and the types didn't match. I now loop with an Object and then use CType, but that's...
27
413
by: Craig Buchanan | last post by:
Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string. I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match, but I thought there might be an easier way. Thanks,
2
3732
by: Ian Gore | last post by:
Hi, I'm relatively new to VB.NET so I'd be grateful if someone could point out what I don't understand here... 1) Creating a strongly typed collection by inheriting CollectionBase. This is covered in most of the books I've read. Basically you inherit CollectionBase and then add methods (say Add) that takes your types as a parameter and then calls List.Add from the base class. OK. However CollectionBase exposes the IList interface...
3
1350
by: Michael Fällgreen | last post by:
Hi, I need to make a strongly typed collection of x, and the simplets way is to inherits list(of x). With that I can bind to a list-control. However - i don't need all the methods from list(of x). If I make a private list as list(of x) in a class and implements IList(of x) I can control what methods to be public. I works - but now I can't bind the collection to a listbox og grid (it says something about complex datatype).
3
3545
by: GBR | last post by:
I have a collection object inherited from collection base that is used to carry my object entities from server to client through a web service. I want to add a dataset to this collection object and send it across. But when it gets to the web server, its failing. Any help would be abvised? Is this possible? Can I add a dataset object and add it into the collection array and pass it across?
6
5641
by: SharpCoderMP | last post by:
hi, until .net 2.0 i've been writing my own collections derived from CollectionBase. Now with the generics it is much easier to do that... but! i have some questions about generic lists of complex objects. consider this short example: class MyComplexClass : IDisposable {
14
1700
by: cwineman | last post by:
Hello, I'm hoping to do something using Generics, but I'm not sure it's possible. Let's say I want to have a bunch of business objects and a data access class cooresponding to each business object. For each business object, I would have something like below: public class Apple { //apple stuff
11
1865
by: Bit Byte | last post by:
I am writing a generic container class which I want to support the 'foreach' statement. My class looks something like this: class MyClass<T: CollectionBase { //Implementation for MyClass<Tgoes here ... // ...
0
8696
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9050
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7906
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5938
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4448
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4709
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3147
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2500
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.