[dba-VB] C# serialization

jwcolby jwcolby at colbyconsulting.com
Tue Oct 13 10:59:49 CDT 2009


That's nice Charlotte, but I assume that I would have to completely rewrite some level of how I do 
things.  I would certainly welcome knowing how to do that but I don't want to do so at this moment. 
   If this has anything to do with ADO and all of that stuff, I will be getting into that later.

A year or so ago I used something similar to what I am doing now and just used serialization to 
write it out to a stream and later read it back in.

I know from experience that once you are up to speed on the syntax of a language, it is easy to 
forget what a PITA all the nitpicking details are.  I am still dealing with [] instead of () for the 
collections, explicit data type conversions and all the rest of the stuff that you don't even 
remember learning.  "Building a typed dataset" of any kind is not where I am right now, never mind 
"on an XML file".

Have patience Master.

John W. Colby
www.ColbyConsulting.com


Charlotte Foust wrote:
> You can build a typed dataset on an xml file John.  Doesn't require a
> database.
> 
> Charlotte 
> 
> -----Original Message-----
> From: dba-vb-bounces at databaseadvisors.com
> [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
> Sent: Tuesday, October 13, 2009 8:38 AM
> To: Discussion concerning Visual Basic and related programming issues.
> Subject: Re: [dba-VB] C# serialization
> 
>  >Do these classes inherit typed datasets?
> 
> Nope, no connection to a database.
> 
> The original assignment was to build a grade calculator where you simply
> input a list of grades. 
> There are three types of grades, each with a different weight (Tests -
> 40% of grade, Labs - 50% of grade and DL 10% of grade).
> 
> There is no requirement to do anything more than the above, calculating
> a total count of each grade type, sum of each type, average of each type
> and weighted average of each type, and then the same calculations for
> the totals.
> 
> In order not to be bored to death, and with the approval of the
> instructor, I expanded the assignment to include using classes and
> collections.  I store each grade in an instance of clsGrade. 
>   I store all of each TYPE of grade in an instance of clsGrades (plural)
> which contains a generic collection into which the instances of clsGrade
> are inserted.  This collection is strongly typed so that it can only
> accept clsGrade objects.
> 
> Each instance of clsGrades (plural) is inserted into a sorted list in
> clsCalculator, keyed on GradeType (keyed on the string "Test", "Lab" or
> "DL").  In the main form there is a combo with three grade type strings
> ("Test", "Lab" and "DL") which when selected is passed in to
> clsCalculator which indexes into the collection to access the correct
> instance of clsGrades.  Adding new grades, deleting grades and updating
> existing grades is all done on the selected instance of clsGrades.
> 
> So...
> 
> clsCalculator - interfaces to the form and has a sorted collection
> holding three instances of...
> clsGrades - contains a strongly typed generic collection holding
> multiple instances of ...
> clsGrade - contains each grade.
> 
> clsGrades performs the calculations to count (collection.count), sum,
> average and weighted average all of the grades contained within.
> 
> clsCalculator requests the various computed values from the three
> instances of clsGrades and performs the calculations to create an
> overall Count (sum of clsGrades.Count), Sum (sum of clsGrades.Sum),
> Average, weighted sum etc.
> 
> Now...
> 
> I want to write the grades in each clsGrades instance to a single file,
> then read it back in again. 
>   Persist the grades to disk.  I have no requirement to persist the data
> to disk, I simply want to do so.
> 
> Please please please do not suggest a "better way" for doing the
> assignment, it is all written and functions exactly as you would expect
> it to work.  You may of course enlighten me on different options, but I
> will not be rewriting the core assignment at this point.
> 
> This was just a homework assignment and it is in fact finished.  If I
> can persist it great, if not that's OK too.  I have learned a lot and
> thought I might learn how to do the persist thing, streams,
> serialization (if that is used) etc.  Even classes and collections are a
> "next semester" thing so I am ahead of the curve at this point.
> 
> John W. Colby
> www.ColbyConsulting.com
> 
> 
> Charlotte Foust wrote:
>> John,
>>
>> I'm not sure I understand what you're doing.  Do these classes inherit
> 
>> typed datasets?  If so, the parent class can easily return a child 
>> class that already contains a typed dataset of child records.  You 
>> don't actually need collections for that.  In that case, grade 
>> wouldn't need to be a class (although it could be, I just don't see 
>> any need).  The
>>
>> Charlotte Foust
> 
> _______________________________________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-vb
> http://www.databaseadvisors.com
> 
> 



More information about the dba-VB mailing list