473,398 Members | 2,404 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,398 software developers and data experts.

Collection of custom entities

what is the best way to implement collection
of custom entities?
Jul 19 '05 #1
3 2865

If your "entities" are objects, just create an ArrayList and put them in
there..

ArrayList entities = new ArrayList();
entites.Add(my_entity);
Jul 19 '05 #2
In general, a strongly-typed class is the way to go. The
only things you really need to be aware of are the
following:
The arraylist has less overhead, however it is much less
flexible. It can also be used as a datasource. But, it
can be referenced by index only.

The CollectionBase is flexible, can be used as a
datasource and can be accessed by Index. It is very fast
when accessing by Index. The only major drawback is that
you can't access items by Key. To do this you can do what
I do which is to create an Item(Key as string) method
which can loop through the collection looking for
your "Key" value in the objects. You can also extend it
to return the collection in a sorted order.

The DictionaryBase is the other major option. This is a
name/value collection and the items can only be accessed
by key. The collection cannot be used as a datasource and
you must use a for..each loop to look through everything.
In general, if you don't know the key then this is a bad
type of collection to use. Also, the order the data is
returned is not necessarily the order they were added in.

The choice is pretty wide open, but I'm a big fan of the
collectionbase and extending it. However the choice will
depend on the type of project and the tradeoffs you want
to make.

Jeff Levinson

Author of "Building Client/Server Applications with
VB.NET: An Example Driven Approach"

-----Original Message-----
My entities are objects. And I think ArrayList is very
good and simple solution. My concern is regarding type-
safety. As I understand Microsoft encourages developer touse strong-typed classes. It also eliminates late bindingissue. To solve my problem, I wanted to create a custom
collection (inherited form CollectionBase, for example)
for each business entity. I don't know if I'm doing a
right thing.
-----Original Message-----

If your "entities" are objects, just create an
ArrayListand put them in
there..

ArrayList entities = new ArrayList();
entites.Add(my_entity);
.

.

Jul 19 '05 #3
My entities are objects. And I think ArrayList is very
good and simple solution. My concern is regarding type-
safety. As I understand Microsoft encourages developer to
use strong-typed classes. It also eliminates late binding
issue. To solve my problem, I wanted to create a custom
collection (inherited form CollectionBase, for example)
for each business entity. I don't know if I'm doing a
right thing.
-----Original Message-----

If your "entities" are objects, just create an ArrayList and put them inthere..

ArrayList entities = new ArrayList();
entites.Add(my_entity);
.

Jul 19 '05 #4

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

Similar topics

7
by: mittal.pradeep | last post by:
What is the better table design for a data collection application. 1. Vertical model (pk, attributeName, AttributeValue) 2. Custom columns (pk, custom1, custom2, custom3...custom50) Since the...
3
by: jamie_m_ | last post by:
I have a custom collection ... clFile that INHERITS from NameObjectCollectionBase the problem is, when I try to create an xmlserializer instance i get an error You must implement a default...
2
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...
2
by: Islamegy® | last post by:
I have started to implement Strongly typed CustomCollection for my Entities instead of using Dataset & Datatable.. All my Collection Classes inherit from CollectionBase.. I tried to serialize my...
1
by: jamie_m_ | last post by:
I have a custom collection ... clFile that INHERITS from NameObjectCollectionBase the problem is, when I try to create an xmlserializer instance i get an error You must implement a default...
3
by: GrumpyDev | last post by:
what is the best way to implement collection of custom entities?
3
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...
4
by: John Dalberg | last post by:
I noticed the starterkits timetracker & issue tracker load data from a database into custom collections (arraylists) which bind to a datagrid. What are the advantages of using custom collections...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.