Question about design

R

razael1

Let's say, for example, that I want to represent universities in XML.
Each university has any number of buildings, departments, and offices.
Which of these is better?

Option A:
<university>
<building>
<name>...</name>
</building>
...(include all buildings)
<department>
...(do the same for departments and offices)
</university>

Option B:
<university>
<buildings>
<building>
...
</buildings>
<departments>
<department>
...
</departments>
etc.
</university>

Are putting the different types of objects in their own groups
redundant, or does it make things clearer/more organized?

Thanks,
Colin K.
 
J

Joe Kesselman

Are putting the different types of objects in their own groups
redundant, or does it make things clearer/more organized?

As with any other programming data-structure design issue, this is as
much a matter of style as anything else. If you were designing these as
structures/objects in your favorite programming language, which
organization would you prefer? The answer probably depends on which
operations you're going to be doing most often. Approach the XML design
the same way.

Generally, there's no harm in having an extra level of hierarchy in your
data structures.

However, I would suggest using attributes for values which describe a
datum rather than being contained within it. Specifically, I would prefer
<building name="...">
rather than making name an element, unless the name is itself a
structured datum.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,006
Messages
2,570,265
Members
46,861
Latest member
SanoraS48

Latest Threads

Top