I've been working on a personal project that uses a multi-dimensional array. Actually, I've been struggling to try and think of a better way to represent the data. And, hey, maybe you guys might have some ideas. In fact, I think someone here mentioned they work with or might pursue a job that deals with HL7 (Health-Level 7) messages. Doesn't matter, many data messages are structured similarly.
Okay, so here's the deal: HL7 messages look like this:
Each line represents a segment (MSH, PID, NK1, PV1). Within each segment are sequences (the pipe [ | ] delimiter). Within each sequence there are components (the caret [ ^ ]). There are also subcomponents ( & ) and repeats ( ~ ) but are rarely used in my experiences.
I am creating a parser utility for the guys at work that will break down the message into a HTML table so they can more easily examine the data. I have a working tool, so no problem there, but what I ended up doing is simply splitting off of the 3 delimiters - carriage returns (for segments), pipe, and then caret. So you end up with a multi-dimensional string array - string[][][]. However, it's very cumbersome to work with and the code is confusing. I really can't think of a way to represent this data via class structures. You would basically end up with something like an array: Message being a List of Segments, Segments being a list of Sequences, and Sequences a List of Components. It's like Russian dolls and it gets confusing fast. And, it can get deeper than that if one needs to deal with the above mentioned subcomponents and repeats.
Oh, and if anyone actually gives a shit, this is what the parsing tool outputs: