How to track 100 items with 8 status indicators

T

Tony M

VS 2008 / VB / XP / Winform

I need to create a status machine.
I need to track 100 items.
Each item has about 8 things to track.
I don't want to use files and records b/c I will constantly be reading and
writing to disk.
I need to look at indexes (1) then maybe indexes (65) in random order. And
update the indexes randomly also.

I guess it looks like 100 records with 9 fields.

I tried
Dim ary(100, 100, 100, 100, 100, 100, 100, 100, 100)
this would work but seems like allot of waste. I will never need to look at.
ary(1,2,1,1,1,1,1,1,1)
or
ary(1,1,1,1,1,1,1,1,2)
only
ary(1,1,1,1,1,1,1,1,1)
ary(2,2,2,2,2,2,2,2,2)
ary(3,3,3,3,3,3,3,3,3)
....
ary(100,100,100,100,100,100,100,100,100)

and so on...

I looked at Jagged arrays, just having a hard time wrapping my head around
it.
Is jagged arrays the way to go or is there a better solution?

One problem is in either case I'm stuck with either numeric or string
indicators.
I can live with that.

Thanks
 
M

Miro

What would be the problem in creating a "typed dataset"...

Even if it is from a file ( you dont have to ), but if it is...just dont
call "update".

The dataset is in memory so if you are constantly reading and writing to the
dataset and not
updating an underlying data file, you shouldnt see much of a performance
hit.

The pluses of this as well, is that the "layout" is easy to change and you
can treat it just as if it
was a record with 10 fields or whatever.
Even make the dataset contain 2 tables and add a relation.
File 1 to many relation.
That would solve your "jagged" array problem too with them having "about" 8
items.


-Just a thought.

Miro
 
T

Tom Shelton

What would be the problem in creating a "typed dataset"...

Even if it is from a file ( you dont have to ), but if it is...just dont
call "update".

The dataset is in memory so if you are constantly reading and writing to the
dataset and not
updating an underlying data file, you shouldnt see much of a performance
hit.

The pluses of this as well, is that the "layout" is easy to change and you
can treat it just as if it
was a record with 10 fields or whatever.
Even make the dataset contain 2 tables and add a relation.
File 1 to many relation.
That would solve your "jagged" array problem too with them having "about" 8
items.

-Just a thought.

Miro

Another advantage, since the op seems to be using 2008 would be the ability to
query the dataset using Linq to DataSet. Very handy that.

I will say, I do shy away from typed datasets some. Though, if the OP wanted,
they could easily load and save the data using the DataSet.ReadXml/WriteXml
methods.
 
F

Family Tree Mike

Tony M said:
VS 2008 / VB / XP / Winform

I need to create a status machine.
I need to track 100 items.
Each item has about 8 things to track.
I don't want to use files and records b/c I will constantly be reading and
writing to disk.
I need to look at indexes (1) then maybe indexes (65) in random order. And
update the indexes randomly also.

I guess it looks like 100 records with 9 fields.

I tried
Dim ary(100, 100, 100, 100, 100, 100, 100, 100, 100)
this would work but seems like allot of waste. I will never need to look
at.
ary(1,2,1,1,1,1,1,1,1)
or
ary(1,1,1,1,1,1,1,1,2)
only
ary(1,1,1,1,1,1,1,1,1)
ary(2,2,2,2,2,2,2,2,2)
ary(3,3,3,3,3,3,3,3,3)
...
ary(100,100,100,100,100,100,100,100,100)

and so on...

I looked at Jagged arrays, just having a hard time wrapping my head around
it.
Is jagged arrays the way to go or is there a better solution?

One problem is in either case I'm stuck with either numeric or string
indicators.
I can live with that.

Thanks


I must be missing something. Why not:

dim ary(100,8)

?

The first index is the "item", the second index is the "things to track".
 
M

Miro

Hi Tom,

Any reason you shy away from typed datasets?

I am pretty new to vb.net but don't they make programming stuff like easier?
What would be the downfall of "not to use it"?

Thanks,

Miro
 
J

James Hahn

What you are referring to is known as a rectangular array, or just a
2-dimensional array.

Dim ary(100, 9)

Think of it as 100 columns by 9 rows where the columns are the items and the
rows are the details you need to track for the corresponding item.

You will need to establish which column relates to which detail, in the same
way that you need some method for relating each item to a row number..

So the size of item 65 is ary(65,4) and the weight of item 12 is ary(12,6)
and the color of item 21 is ary(21,3) and the quantity in stock of item 32
is ary(32,0) and so on.

Other solutions would permit using names for items and.or details. The
two-dimensional array is by far the simplest structure to use, but it is not
as powerful as some other options.
 
T

Tom Shelton

Hi Tom,

Any reason you shy away from typed datasets?

I am pretty new to vb.net but don't they make programming stuff like easier?
What would be the downfall of "not to use it"?

Thanks,

Miro

Well, they are a pain if the data source changes. That's the main reason.
Generally, I'm engaged in multi-tier applications, and so i don't much use
datasets in general. Mostly, custom buisness entities.
 
C

Cor Ligthert[MVP]

Tom,
Well, they are a pain if the data source changes. That's the main reason.
Generally, I'm engaged in multi-tier applications, and so i don't much use
datasets in general. Mostly, custom buisness entities.
I had the same with the older versions were all kind of code was generated
in the component where it was used (which was without multilayer's mostly a
form), now with the XSD versions it is much simpler to regenerate a
dataset.

Cor
 
T

Tom Shelton

Tom,

I had the same with the older versions were all kind of code was generated
in the component where it was used (which was without multilayer's mostly a
form), now with the XSD versions it is much simpler to regenerate a
dataset.

Cor


Oh, I'm sure like most things it's gotten better - but, you know once a ship
has sailed :)
 
M

Miro

Thanks Tom,

I was just curious... I just wanted to make sure I was on "the right idea"
of thinking about the dataset.
I just couldnt think of any pitfalls when you mentioned you stay clear of
them.

You are right ( i beleive ) from learning expierience...
and it could just be me cause I havn't learned how to properly do this yet,

But I hate making changes to my dataset in my program, I seem to take
forever trying to
fix forms that died or something.
(example - removing a field from a dataset and adding a new one ).

Cheers'

Miro
 
T

Tony M

Thanks,

I'm trying to write some VoIP and need to track channels and there status.

a(100,8) will work fine, I will have to assign integer values to all status
information but that's ok.

I just couldn't see the trees through the forest!!!

Thanks
 

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