Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Serialising objects which change alot

Serialising objects which change alot

Scheduled Pinned Locked Moved Visual Basic
regextutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cnurse
    wrote on last edited by
    #1

    I'm developing an object hierarchy which is beginning to stabilize now, but still things pop-up where I need to add a property to an object. This buggers up my serialized data, as after I add the property, run the app and deserialize, the member count doesn't match. Any suggestions on how to cope with this. I could do exports to comma sep to work around, but what do you do when you throw out a production system to the world. Writing data conversion stuff is a right PITA. Well, I await your expert input. Thanks Nursey

    C 1 Reply Last reply
    0
    • C cnurse

      I'm developing an object hierarchy which is beginning to stabilize now, but still things pop-up where I need to add a property to an object. This buggers up my serialized data, as after I add the property, run the app and deserialize, the member count doesn't match. Any suggestions on how to cope with this. I could do exports to comma sep to work around, but what do you do when you throw out a production system to the world. Writing data conversion stuff is a right PITA. Well, I await your expert input. Thanks Nursey

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Design your system first. If done properly the only changes you need to make will be minor. --Colin Mackay--

      EuroCPian Spring 2004 Get Together[^]

      C 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Design your system first. If done properly the only changes you need to make will be minor. --Colin Mackay--

        EuroCPian Spring 2004 Get Together[^]

        C Offline
        C Offline
        cnurse
        wrote on last edited by
        #3

        Not the answer, "...commandment 11...and lo, users shall never change their minds..." mmmmm 8-) So how do you cope when things changes? Nursey

        C 1 Reply Last reply
        0
        • C cnurse

          Not the answer, "...commandment 11...and lo, users shall never change their minds..." mmmmm 8-) So how do you cope when things changes? Nursey

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Yes, users will always change their minds so change is going to happen, but what I meant was that since the object heirarchy was in flux it should still be in the design phase. As it is now beginning to stabalise it can be moved to development phase. Changing it will still take some grunt work as you know already, but if it was changing so much before now I wonder why you were writing the code for it. --Colin Mackay--

          EuroCPian Spring 2004 Get Together[^]

          C 1 Reply Last reply
          0
          • C Colin Angus Mackay

            Yes, users will always change their minds so change is going to happen, but what I meant was that since the object heirarchy was in flux it should still be in the design phase. As it is now beginning to stabalise it can be moved to development phase. Changing it will still take some grunt work as you know already, but if it was changing so much before now I wonder why you were writing the code for it. --Colin Mackay--

            EuroCPian Spring 2004 Get Together[^]

            C Offline
            C Offline
            cnurse
            wrote on last edited by
            #5

            I think you have made assumptions about what this project is, its size and budget etc. I want to focus on how people cope with protecting their data using .NET serialization here. Let's just pretend it's a bedroom application, where we all cut code without UML, patterns and our refactoring handbook at the ready. If you serialize data with comma sep as your chosen data format, its a trivial matter to deserialize a different number of members to that which was serialized. My only interest here is in trying to abide by .NET's serialization techniques, purely for learning purposes. If .NET is going to throw an exception every time I add another property to my objects, and if .NET offers no alternative, then I need to reconsider my data storage techniques. Any talk of design and the like is off topic, and I've been there and done it all before, so I need to stick to what I don't know about, please. Nursey

            R 1 Reply Last reply
            0
            • C cnurse

              I think you have made assumptions about what this project is, its size and budget etc. I want to focus on how people cope with protecting their data using .NET serialization here. Let's just pretend it's a bedroom application, where we all cut code without UML, patterns and our refactoring handbook at the ready. If you serialize data with comma sep as your chosen data format, its a trivial matter to deserialize a different number of members to that which was serialized. My only interest here is in trying to abide by .NET's serialization techniques, purely for learning purposes. If .NET is going to throw an exception every time I add another property to my objects, and if .NET offers no alternative, then I need to reconsider my data storage techniques. Any talk of design and the like is off topic, and I've been there and done it all before, so I need to stick to what I don't know about, please. Nursey

              R Offline
              R Offline
              Ray Cassick
              wrote on last edited by
              #6

              I hate to say it but I think this is something that is going to be bad for you. Just think of what it is like way back when they created Microsoft Word 1.0. You saved (serialize) something into a .doc format and saved it. Then after several years they significantly changed the doc format so that the new type is not backwards compatible. This is why they make document converters and why programs allow you to import data from older versions. The only thing I can think of would be to add a version number to your class that will get serialized out then when you read it in you can change the deserialize method of the class to check for the version and handle any known conversions as needed. I can see this as getting a but messy though if you are going through many lifecycles. Depending on what you are trying to do, if the formats are going to change a lot maybe you want to store your stuff in a database. This is simpler to add columns to and then as long as you don’t change the format of the existing data too much adding new things is not that hard. It is a catch 22 though. Using regular serialization is simpler because you have less to do, but in your case I think it is ending up being more of a pain than just putting a bit more work into making your storage mechanism a but more robust and less brittle.


              Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall." George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things." Jörgen Sigvardsson wrote: If the physicists find a universal theory describing the laws of universe, I'm sure the asshole constant will be an integral part of that theory.


              C 1 Reply Last reply
              0
              • R Ray Cassick

                I hate to say it but I think this is something that is going to be bad for you. Just think of what it is like way back when they created Microsoft Word 1.0. You saved (serialize) something into a .doc format and saved it. Then after several years they significantly changed the doc format so that the new type is not backwards compatible. This is why they make document converters and why programs allow you to import data from older versions. The only thing I can think of would be to add a version number to your class that will get serialized out then when you read it in you can change the deserialize method of the class to check for the version and handle any known conversions as needed. I can see this as getting a but messy though if you are going through many lifecycles. Depending on what you are trying to do, if the formats are going to change a lot maybe you want to store your stuff in a database. This is simpler to add columns to and then as long as you don’t change the format of the existing data too much adding new things is not that hard. It is a catch 22 though. Using regular serialization is simpler because you have less to do, but in your case I think it is ending up being more of a pain than just putting a bit more work into making your storage mechanism a but more robust and less brittle.


                Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall." George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things." Jörgen Sigvardsson wrote: If the physicists find a universal theory describing the laws of universe, I'm sure the asshole constant will be an integral part of that theory.


                C Offline
                C Offline
                cnurse
                wrote on last edited by
                #7

                Ray, Replies like yours are the reason I love this web site, well thought out, constructive and strictly in the vein of the problem. Thanks you. I think I have a partially thought out solution... If I serialize class A and want to add members to it then I should derive A using class B and add the members there. I can call A.Serialize from B.SerializeOldVersion, get me? Then I can B.Serialize and B.Deserialize and all my new members will be handled correcly. OK, its partially thought out because if there are relating objects then those relationships could mudy the water somewhat. But in theory, this meets the "don't change your interfaces" school of thought. I think deriving would certainly be the way through to data conversion though, then effectively you can roll all the stuff up into one class again. My ambitious thoughts are in this area though. As I am using SOAP format for serialization as oppose to binary format, at least for the time being (there's nothing quite like being able to see your megabytes of data in text format hehehe) well...to cut a long one short, there ought to be a structured way of massaging the data. i.e. you could write an XML parser, which a very good friend of ours on here has done recently, and insert the new fields where neccessary...then hey presto. I think there is definite potential in this approach. Again, your additional thoughts are very welcome. Many thanks. Nursey

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups