1. Computing & Technology

Discuss in my forum

David Bolton

Serialization in C#, Faster than a DB?

By , About.com GuideMarch 17, 2009

Follow me on:

Back in the late 80s early 90s, long before databases were commonplace, I was programming in Turbo Pascal and Watcom C++ and I used flat files for data storage. Both Dos and Windows supported this with random access files and this technique was successfully used in many postal games I programmed such as the 1,000 player game Quest. Reading and writing arrays, strings and records (pascal equivalent of a struct) to disk was very fast.

I'm trying something of the same now using serialization as an experiment with a game server that I'm writing in C#. The game data for one game is split among 17 classes so the idea is that multiple games are held in a game cache in ram. If the server tries to update a game that isn't in the cache then it creates an empty game instance and loads it quickly using the serialized data. Unlike C or C++ where structs are contained in memory and you can dump the contents, it's much better to use serialization, convert the members to a stream of binary and write that. Greg Young has an interesting example. I'll let you know how I get on.

Comments
No comments yet.  Leave a Comment
Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>
Related Searches serialization march 17

©2012 About.com. All rights reserved.

A part of The New York Times Company.