A couple of weeks ago, I asked whether people would find an exploration of ways to count things useful. The consensus was "yes", so I've started drawing up notes. While working on them, it occurred to me that "ways to persist things" might be just as interesting. Some of the approaches that could be discussed are:
- Save a list of numbers (one per line).
- Save a matrix using a header line to record dimensions (introducing the idea of metadata) and M values per line.
- Save a matrix without metadata (which requires the length of the second and subsequent lines to be checked).
- Save mixed atomic values (which gets hard when strings are allowed).
- Saving records whose structure is known in advance (the hardest of the bunch, since this is the point where aliasing appears).
- Saving in binary rather than ASCII.
- Creating self-describing data (save the format at the top, then the data).
What other persistence patterns do you think would be worth explaining, and why?