开发者

Save file format

So we've got an app that needs to save and load its state from disk.

We've got the state in an object currently and that object is being serialized directly to XML with the XML serializer object. I've gone over this with the other developer on the project and he seems to think this is the perfect way to go about it. He asserts that having the model on disc being exactly like the representation in memory is ideal.

I feel that the way the data is saved to disk needs to be decoupled from its representation in memory so that we can modify one or the other without it being a breaking change for the saved format. Not to mention that the XML serializer requires everything needs to be read/write where in the object there may be many cases that need to be read only.

The question is the开发者_开发百科re a best practice in regard to serializing in memory data to XML. Is it better to hydrate your object directly from the XML, or decouple the process by using an objects whose sole purpose is to be feed into the XML serializer?


It sounds like you are pointing out the negatives of his solution, but not really offering a good alternative.

So either:

a) Use his solution until it doesn't work anymore

or

b) Come up with your own solution that addresses the issues that you pointed out.

One thing that might be worth exploring: you could look at an object database like db4o, which might be able to handle saving/loading of object(s) and most changes you make to the class, but might not be ideal for the case where you want to be able to directly edit the on-disk state (you CAN do it, but you'll have to jump through a few hoops).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜