Click here to Skip to main content
15,885,900 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi There,

i have about 50 classes (C# 2010) or so that will get updated periodically with new content on the class structure itself.

Whether it's some field that would be added, removed or renamed.
At the end of the day i need to allocate anything from 1 to a few thousand instances of a class, which gets hold together with dictionaries.
Then output on a 3d graphics device.

I'm looking at saving / loading between the classes and local database for the class content. The classes contains protected fields and members as well.

I've done some research on the 2 different serialization options.

I'm trying to find a way how to accomodate binary serialization perhaps in conjunction of preserving the loading of the data from the original class state.,
when the structure of the class has been changed from the previous xml save.

Any advise would be appreciated.

Regards,
X
Posted

1 solution

"i have about 50 classes (C# 2010) or so that will get updated periodically with new content on the class structure itself." = Isn't it sounds rewriting the application often? or you meant to say instance of the classes?

"I'm looking at saving / loading between the classes and local database for the class content" Again make it clear the classes or instances?. If it is classes then it gives me an idea of directing a movie "Transformers 50" and how the dependents adapted to them.

However for xml serialization you can mark a field optional When your class structure changes you can make the new fields optional. So that still you can deserialize the old version of the object and have some business logic at the deserialization events to populate those uninitialized fields. Hope that helps.

Some old school people said "Classes should be closed for modification and open for extension". Now it is time to rethink if you have a vital requirement for this.
 
Share this answer
 
Comments
Sandeep Mewara 16-Apr-11 12:48pm    
My 5! No idea why and who voted 1.
Albin Abel 16-Apr-11 13:45pm    
Thanks Sandeep. May be Op didn't like the answer.
Sandeep Mewara 16-Apr-11 14:32pm    
Yeah... surely he didn't. It's clear it was some rookie ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900