CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2002
    Location
    Delhi, India
    Posts
    67

    What is a Serializable class?

    Can anyone explain to me what is a Serializable class and what is the significance of Serialization? Please try to be as clear as possible as I'am new to VB.NET.
    While BUG_IN_PROGRAM
    ApplyPatch
    wend

    Private Sub ApplyPatch
    BUG_IN_PROGRAM = True
    End Sub

  2. #2
    Join Date
    Dec 2002
    Location
    London, UK
    Posts
    1,569

    Re: What is a Serializable class?

    For a class to be serializable means that it can be turned into a self describing XML (or binary XML) format.

    The advantage of this is that you can serialize a class, store it (say in a database) and some time later pull it out and de-serialize it and you'll get back the exact same object you had before... even if the application which deserializes the class doesn't know the structure of the class.

    Does that help you?
    Mike

  3. #3
    Join Date
    Jan 2002
    Location
    Delhi, India
    Posts
    67

    Re: What is a Serializable class?

    Thanx very much for the valuable information!
    While BUG_IN_PROGRAM
    ApplyPatch
    wend

    Private Sub ApplyPatch
    BUG_IN_PROGRAM = True
    End Sub

  4. #4
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: What is a Serializable class?

    Ok that sounds good, but why would I want anything to be serializable and what makes a class serializable ( I mean what does this class has special beside keywords ). In other words, I don't see what's the point of this.
    Nicolas Bohemier

  5. #5
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: What is a Serializable class?

    One big reason is so you can send it thru a wire to another app.

  6. #6
    Join Date
    Jun 2005
    Posts
    6

    Re: What is a Serializable class?

    I just used this in a program I am improving on for a company in Nova Scotia.

    They use this to create "profiles" of information, which is held in a class to be used in another program.

    We serialize the class to a file, then load that same class when using the actual program.

    Very good way of storing and then moving class information.

    - josh

  7. #7
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: What is a Serializable class?

    Ok I understand.. but what's the difference between serialize in XML and just write the class in a Binary file ?

    Seems to me like both application needs the class definition anyway. So what's the difference ?
    Nicolas Bohemier

  8. #8
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: What is a Serializable class?

    It's the same thing, just a different format.

    Imports System.Runtime.Serialization.Formatters.Binary
    vs.
    Imports System.Runtime.Serialization.Formatters.Soap

  9. #9
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: What is a Serializable class?

    ok so it's just a fancy way of doing things that used to be in place for a long time. So mainly it's another Bell and whistle thing.
    Nicolas Bohemier

  10. #10
    Join Date
    Jun 2005
    Posts
    6

    Re: What is a Serializable class?

    I can tell you that using XML is pretty convenient.

    I am not sure if this is true of most other storage practices, but you can open the XML file with notepad, and see every piece of data, and it's value, which made debugging and understanding this program much easier than it could have been.

    - Josh

  11. #11
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: What is a Serializable class?

    It can be interesting, but also, it's another way to expose your code. Though decompiling assemblies is quite simple if you don't obfuscate it.
    Nicolas Bohemier

  12. #12
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: What is a Serializable class?

    Quote Originally Posted by Boumxyz2
    ok so it's just a fancy way of doing things that used to be in place for a long time. So mainly it's another Bell and whistle thing.
    It is not just bell and whistle thing, XML serialization is required for transmistting data for WEBSERVICE.

    So you serialize your object based on who you want to transmit it to. For example, sending the data to a webservice, you'd use XML but use binary if the endpoint is a .NET remoting service.
    Good Luck,
    -Cool Bizs

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

Featured