Repeating String Fields
Jun 1, 2011It’s a design pattern that I come across fairly often across all sorts of modeling paradigms. It’s a simple one too: a field/property/whatever that is a list of strings of no fixed content. In XML schema, it looks like this:
I also come across it in HL7 v2 specifications, openEHR archetypes, database schemas, application object models, etc.
I’m not talk about fields where the string is a something, where something is a list of characters with a known meaning (code, identifier, etc) - that makes sense.
No, just a plain old list of strings. That do… something. What? The name is suggestive. So let’s stick with the name “comments” (some readers may know exactly what I’m referring to here). What does it means to a have a list of comments. Is
“The result is unexpected. I called you about it”
meaningfully different to
“The result is unexpected”, “I called you about it”
in any way? What does it achieve, offering cardinality > 1?
It seems to me that the model is effectively saying, there’s some hidden semantics here that I don’t tell you about, but they’ll be able to leap out and catch you out later. Maybe:
- the different strings have different sources (and the computer tacking them together is too much work?)
- the strings have unstated meaning
- the strings actually have slightly different meaning depending on order
- later on, some one will have to add more information to the model
All of these are potentially a bad thing. So one of my criteria for a good model is that doesn’t have any strings properties/fields/whatever that can repeat, where it isn’t explicit how the repeats are meaningfully differentiated.