Sunday, 24 January 2010

Attribute or Element Categorisation

So I'm playing with the concept of Object Orientated Software thanks to reading the course stuff from the M255, I'm also listening to FLOSS weekly and browsing my feeds when I come across this article about how our brains are hard-wired for categorisation and I get to wondering... The FLOSS episode was cool because it talked a little about imbedding or referencing and how it was basically a matter of choice but that there could be implications now in terms of performance and also further down the road if you were wanting to change things. It'd be quicker to embed in terms of getting at the data but a shed-load harder to change it later if you needed to trawl through loads of documents in order to find each embedded object. It would be slower to reference the data in terms of retrieving it but a shed load easier to alter it further down the road if it was only the one record that'd need changing. At least I think that that was the general idea. Then I got to thinking about XML and and a discussion that I overheard about whether something should be an element or an attribute within a XML hierarchy. So:

<addressBook>
  <address>
    <street>424 Any Road</street>
    <city>Any City</city>
    <county>Countyshire</county>
    <postcode>AB1 2DE</postcode>
  </address>
  ...
</addressBook>

This is an element-centric approach to an XML document whereas this attribute-centric:

<addressBook>
  <address street="424 Any Road" city="Any City" county="Countyshire" postcode="AB1 2DE">
  ... 
</addressBook>

So I guess that what I'm thinking is that this is quite similar in terms of accessing the data...

Something I need to think about a bit more though so I'll get back to you.

No comments:

Post a Comment