G
Guadala Harry
I have some logic that currently processes values retrieved by looping
through a HashTable/ListDictionary structure (a hash table that contains
ListDictionary objects as its values). Logically it's just a bunch of rows
and columns - just like in a DataTable or row set returned by a DataReader.
You can visualize this as 3 columns and N rows.
I need for the same logic to be able to process identical data - but by
processing DataRows of an ADO.NET DataReader.
I don't want to create two separate methods - one to process the DataReader
and another to process the hash table - as the logic is identical with the
exception being the structure being processed.
I'd appreciate suggestions for having one method that can process both a
DataReader and the hash table structure as described above.
The p-code for the logic currently implemented with a hash table structure
is this:
1. - initialize variables
2 - start loop through hash table
3 - populate 3 string variables from the hash table
4 - process the 3 string variables
5 - finish looping through hash table
6 - return one value to caller
Of course none of the processing logic really cares about the source of the
data (beyond syntax required to loop and to retrieve the 3 string values).
One option is to have the method only process *a* hash table structure. In
this case, the method would receive the hash table as a parameter - and when
null, would create a new hash table structure from scratch and populate it
from the db via a DataReader. Then it proceeds to process the hash table
with no knowledge of where the hash table came from.
Another method is to have the looping logic differentiate between what is
being looped through (hash table or DataReader return set). It would be
capable of looping through either the hash table or DataReader return set
based on some flag variable. I think this code might get kind of ugly
pretty quickly.
Both of these methods would work - but I'd appreciate some other ideas or
feedback on these two.
If you are wondering what's going on here (the bigger picture)... live user
interection is supported by the hash table structure (live user data exists
only in the hash table structure and only optionally saved to the db), while
automated processes work from the saved data only (from the db). I'm trying
to come up with one method that can be used by both live user processing as
well as the automated jobs.
Thanks!
-G
through a HashTable/ListDictionary structure (a hash table that contains
ListDictionary objects as its values). Logically it's just a bunch of rows
and columns - just like in a DataTable or row set returned by a DataReader.
You can visualize this as 3 columns and N rows.
I need for the same logic to be able to process identical data - but by
processing DataRows of an ADO.NET DataReader.
I don't want to create two separate methods - one to process the DataReader
and another to process the hash table - as the logic is identical with the
exception being the structure being processed.
I'd appreciate suggestions for having one method that can process both a
DataReader and the hash table structure as described above.
The p-code for the logic currently implemented with a hash table structure
is this:
1. - initialize variables
2 - start loop through hash table
3 - populate 3 string variables from the hash table
4 - process the 3 string variables
5 - finish looping through hash table
6 - return one value to caller
Of course none of the processing logic really cares about the source of the
data (beyond syntax required to loop and to retrieve the 3 string values).
One option is to have the method only process *a* hash table structure. In
this case, the method would receive the hash table as a parameter - and when
null, would create a new hash table structure from scratch and populate it
from the db via a DataReader. Then it proceeds to process the hash table
with no knowledge of where the hash table came from.
Another method is to have the looping logic differentiate between what is
being looped through (hash table or DataReader return set). It would be
capable of looping through either the hash table or DataReader return set
based on some flag variable. I think this code might get kind of ugly
pretty quickly.
Both of these methods would work - but I'd appreciate some other ideas or
feedback on these two.
If you are wondering what's going on here (the bigger picture)... live user
interection is supported by the hash table structure (live user data exists
only in the hash table structure and only optionally saved to the db), while
automated processes work from the saved data only (from the db). I'm trying
to come up with one method that can be used by both live user processing as
well as the automated jobs.
Thanks!
-G