Storing and maintaining serialized objects in C#

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.

4

I’ve done quite a bit of serialization over the years. Here are some things we came up with:

  • Prefer human readable formats over binary formats. I’d generally prefer Xml to Json mainly because you can use Xslt to transform Xml when you need to upgrade the version.

  • Whatever you are serializing stuff as, the deserialization logic and data storage should allow for versioning of the serialized data. Version info should probably be outside the serialized data, makes it a bit easier to get at and choose the right deserialization strategy.

  • Your serialization should have unit tests running both ways. IE, you should have a test deserializing the data and confirming you get everything imported correctly. And you should have something serialize the data and confirm it comes out as the correct json and xml.

  • If the point of said serialization is cross-platform, test against the other platform. Probably not as much of a problem now as platforms have matured, but there were times when things did not agree on how json should be formatted.

Mentioned points are practical and good to keep in mind. I would like to mention different types of serializations that might be useful to consider depending on your application needs.

  • Binary Serialization – it uses binary encoding to produce compact serialization for uses such as storage or socket-based network
    streams.
  • XML serialization – it serializes the public fields and properties of an object, or the parameters and return values of
    methods, into an XML stream that conforms to a specific XML Schema
    definition language (XSD) document. More info is available in System.Xml.Serialization namespace .
  • SOAP Serialization – it is a different flavor of XML serialization, where it can be used to serialize objects into XML streams that conform to the SOAP specification. SOAP is a protocol based on XML, designed specifically to transport procedure calls using XML. As with regular XML serialization, attributes can be used to control the literal-style SOAP messages generated by an XML Web service.

More information form official source – MSDN C# programming

Also all this need to be practices within SDLC process (meaning having environment to test, version control, etc. )

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật