NET 2.0 and 3.0 offer two completely different methods to serialize object information in to another thing, specifically XML and bytes. This information may assess the 2 practices for you personally, as well as offer some words of wisdom. XML Serialization saves memory when the size of the information included in the subject being serialized is significantly less than the size of the school explanation plus the data within the object. The reason being Binary Serialization contains the class definition within their serialized effects and XML Serialization does not. Check it out
Why do I attention that XML Serialization doesn’t save your self class information? As the serialized XML Data addressing the thing may be deserialized (from XML back to an object) into any subject that you so desire. Provided, obviously, that the type has a title, and Serialization Characteristics occur in the school classification, and they correctly chart to the XML Things that have been made upon the initial XML serialization process.
Because Binary Serialization stores the class data along with the object knowledge, the deserialization process is type safe. Binary serialization assures that that which you serialize into a supply of bytes is exactly what comes from the jawhorse during the time you so choose to deserialize back in an object. That guarantees that the object is reconstructed effectively back to the type that you anticipate it to be. This is the class that you initially instantiated an item from, as if to give delivery to a child. How sad that you then made a decision to get that kid and serialize it into an array of bytes. And thank heavens for Binary Serialization, since you can re-construct your baby without problem, provided you’ve a mention of the the assembly in which your child sleeps.
One warning with serialization; look out for dependencies when sending binary byte or XML in one company to another. At the destination service, when you need to deserialize the bytes or XML, you should have a mention of the assembly that the first type was created into. Be cautious about these find 22 dependencies, and keep things as near to subject or byte range as you can inside the location support, this way you may have no addiction issues.By the way, dependence is bad, in case you haven’t seen it from the electronic grapevine yet.
The XML serialization strategy is ideal for quick and filthy mapping of serializable homes, or mapping to a property that will be complex (a class). But be careful, if the class that you’re deserializing in to is not the first class, and it changes down the road, you may have some very “difficult to establish” bugs humming about your head and creating you headaches. Overall, the binary serialization process is generally more effective, keeping around fifty percent in size when dealing with greater objects.
Nevertheless, if you want to easily read the serialized information, just want to reduce some corners in a most un-professional way, and you’re not worried about bandwidth or performance, XML Serialization is for you. It is merely easier to read XML being delivered from stage A to point N than it is to read a binary stream, but it’s much heavier.
From a practical standpoint, XML is wonderful to utilize for debugging, when you are down in the trenches and on a tight timeline. Use XML Serialization during your code so that you can easily wood an object and see its articles without pressing through a web of pluses and minuses.Use often, or use equally types of serialization if you want them. Ultimately, it depends on your degree of ease, in combination with the requirements around response time for the application.