Home > Content > Another Example of small-p Patterns

Another Example of small-p Patterns

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:

  1. Save a list of numbers (one per line).
  2. Save a matrix using a header line to record dimensions (introducing the idea of metadata) and M values per line.
  3. Save a matrix without metadata (which requires the length of the second and subsequent lines to be checked).
  4. Save mixed atomic values (which gets hard when strings are allowed).
  5. Saving records whose structure is known in advance (the hardest of the bunch, since this is the point where aliasing appears).
  6. Saving in binary rather than ASCII.
  7. 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?

Categories: Content Tags:
  1. June 25th, 2010 at 02:11 | #1

    Combining 2, 6, and 7, using standard external data formats like HDF to accomplish data persistence needs. Especially nice since many analysis tools like Matlab, Octave, Mathematica, etc. can read these directly without platform-specific gotchas.

  2. June 25th, 2010 at 13:24 | #2

    Where do (dtd-less) XML or JSON fit into this list? They’re not really self-describing, but hopefully people (not computers) will be able to figure out the format.

    Later,
    Blake.

  3. June 25th, 2010 at 13:52 | #3

    Both of above more or less fall into what I was going to say which is…

    “Use an existing format / protocol / library”.

    Also the opposite is also a pattern (although in my opinion, more usually an anti-pattern):

    “Use a novel format”.

    There’s also…

    “dump it raw and process in the viewer” (data light / heavy viewer)
    “dump it processed and merely display in the viewer” (data heavy / light viewer).

    “record state versus record stream”

  4. Will
    July 2nd, 2010 at 02:44 | #4

    CSV files are special cases of cases 5 and 7.

  1. July 8th, 2010 at 19:28 | #1