|
-
Apr 12th, 2008, 04:08 PM
#1
Do you SERIALIZE and DESERIALIZE objects?
If so - please explain some practical reasons that you use this.
Thanks!
Last edited by szlamany; Apr 12th, 2008 at 07:38 PM.
-
Apr 12th, 2008, 04:35 PM
#2
Re: Does you SERIALIZE and DESERIALIZE objects?
Well, I've used serialization for a wide variety of purposes. One would be to serialize a class or structure and send it over the network to another application, where its deserialized back into a class instance.
Another thing is just settings of different sorts. Say you have a class full of properties that represents different settings a user can set. This class can be serialized to a file at shutdown and deserialized back into a class instance at startup. This would also allow for the user to save different setting files, each with a different setup, and then let them choose wich setting file they want to load.
-
Apr 12th, 2008, 05:13 PM
#3
Re: Does you SERIALIZE and DESERIALIZE objects?
Transmission and persistence.
I think an example that will hit home is persisting objects to a database.
-
Apr 12th, 2008, 05:14 PM
#4
Re: Does you SERIALIZE and DESERIALIZE objects?
Thanks - makes sense.
Could you tell me the purpose of your two applications that need the class sent over the network.
I'm looking for real world uses.
-
Apr 12th, 2008, 06:17 PM
#5
Re: Does you SERIALIZE and DESERIALIZE objects?
hmm good question, one would think that it should be easy to say an example but only one thing comes to mind;
I made an online minesweeping game, where the one hosting the game would randomly generate a big gaming board on which the game would take place. After generating this board, it was serialized and sent over to the other game participants, so everyone had identical game boards.
Another, pretty darn useless, example of serialization can be found in my signature; its a class that lets you serialize the entire layout of a form into a single file and deserialize back again. I suppose it could be useful if you're looking to create some sort of user interface where the user can rearrange stuff as he likes. Other than that, pretty useless
-
Apr 13th, 2008, 08:28 AM
#6
Re: Do you SERIALIZE and DESERIALIZE objects?
One example is one that you know already - web services.
You have a web service sitting on one of your boxes which has a method called GetCompleteStudentProfile(). It returns a StudentProfile object, complete with images, marks, student nicknames, teachers and so on. You can have an entity layer which contains the StudentProfile with all of the specified fields and if you've marked it serializable, it can be sent over the wire in a text format. It helps to send something in such a format as firewalls 'trust' it more than binary format being sent from machine to machine.
I'll think of a non web-service example.
-
Apr 13th, 2008, 09:02 AM
#7
Re: Do you SERIALIZE and DESERIALIZE objects?
One example I've used is persisting your own Settings class between application sessions. If using the config file is not appropriate for some reason, saving your own class instance to a file and reloading it in four lines of code each is sweet. Network transmission of data is probably the most common use though, and Web Services the most glamorous.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|