What are the best practices to store and maintain serialized objects in C#? Any strategies or patterns that apply?
What I have come to believe so far is this:
- Prefer Json over XML, both for space and for speed, but xml is easier to query/mine data via LINQ to XML for bigger data sets.
- For every single property, map explicitly to a serialized name. In the future, when you need to rename a property, your serialized data won't break. Attributes help with this.
- Store some kind of version info on the serialized object, in case you need to mass-migrate data in the future
Update: (that I found out the hard way)
- Store all datetimes in a uniform way throughout the whole application and throughout all versions. Both concerning format and time zone.