Results 1 to 7 of 7

Thread: Do you SERIALIZE and DESERIALIZE objects?

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Does you SERIALIZE and DESERIALIZE objects?

    Transmission and persistence.


    I think an example that will hit home is persisting objects to a database.

  4. #4

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width