From: Robert Klemme Date: 2009-03-03T16:29:00+09:00 Subject: Re: Marshal.load does not create new instances? On 03.03.2009 04:38, Mike Gold wrote: > Robert Klemme wrote: >> I believe he wants to evolve the class and be able to load data >> written with an older (or just different) version of the class. And >> now Ian hits the usual problems of schema migration. >> >> Ian, you should be aware of one thing: class definitions are not >> serialized - no programming language that I know does this. > > .. except languages in which code and data are equivalent! > > Sorry, I had to bite. Ouch! ;-) > This is a great example of the power of code-data > equivalence. If you store the definitions, things will just work. Well, *certain* things will just work. But you'll trade this for different issues. For example, all of a sudden you can have different implementations of the same class coexist. I wouldn't say that one or the other solution is necessarily easier. They both do not change the complexity of the underlying problem (evolution of code with data artifacts belonging to different versions). Both approaches (i.e. storing code and not storing code) make certain things easy and other things hard. > If you expect the definition to change, you can write adapters which > examine the definition (since it's data!) to detect new or incompatible > changes then adjust accordingly. I'd rather say you _must_ write adapters - otherwise chances are that something will break uncontrollably. > In case there was any confusion from a previous thread, I do use ruby, > as is obvious from my previous posts. I would only suggest that working > around the limitations of a language is not necessarily the best > approach, even though it is typically the default course of action. In > some cases it might be better to use a language without those > limitations. As I understand the particular situation a set of programs written in Ruby was given and their output (marshaled data) needs to be worked with. In this case, choosing a different language does not look like a feasible option. But I generally agree that you should pick the right tool for the job. Kind regards robert