OOP "Collection" of Objects

  • Thread starter Thread starter Ivan Weiss
  • Start date Start date
I

Ivan Weiss

Hi. This is a question I have posted before and have never figured out
a working result. I have been recommended to read some books which I
did which still have not answered my question.

I am writing an application for my office for project management. I
have several classes, one for an employee object, a vendor object, and a
customer object. I want to make an employees, vendors, and customers
object which will contain all or several records from a database for
each class.

For example, I want one datagrid to list all of my customers. I want to
create a customers class which contains all of the customers the
database and than returns the result as one object.

How can I do this following OOP? Or, am I going about it all wrong?

Thanks in advance!

-Ivan
 
Ok, here goes.

Create a "Customer", a "Vendor", and an "Employee" classes that contains the data that you need for each of these instances.

Create a "CustomerCollection", a "VenderCollection", and an "EmployeeCollection" classes. These classes should inherit from which ever collection type that you want to base them on... ArrayList, HashTable, SortedList, DictionaryBase, etc. Insure that either the base class or your collection class implements IList so that you can bind them to the datagrid.

Think long and hard about bringing the entire table of these objects from the database however. I would only do that if 1) There are very few of these items in the database, i.e. < 1000; 2) I was 100% certain that the numbers will not grow by much if at all during the run time of the application; and 3) I knew the memory and possible preformance issues of doing so. I might look into a lazy load methodolgy to only load, for instance, the names and ID's of the records untill more data is requested - on a record by record (or other controlable selection criteria) basis.

HTH
 
Hi Ivan,

There are some complete classes which fits your need

Datarow
Datatable
Dataset
Dataview
and more

They have a lot of events in them, which although you see that seldom in
this newsgroup, make sophisticated validating possible.

They are connected to each other

They are easy to bind to controls

Etc, Etc,

In my opinion are they the most OOP what OOP can be, by instance:

A dataset references datatables which references datarows and columns where
the datarows references items which references to values, and visa versa.

Just my thought,

Cor
 
Back
Top