01.01.2015 Views

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

304<br />

Sunday Afternoon<br />

As mentioned earlier, <strong>UML</strong> Class diagrams are comparable to XML schemas. Both define<br />

the rules for how data is organized. The development team can use their modeling tool’s<br />

XMI functionality to automatically generate an XML schema from the Class diagram, or they<br />

can generate it by hand. I don’t show the XML schema here because reading XML schemas is<br />

a large topic in and of itself. Instead, I show a sample XML document. The <strong>UML</strong> Object diagram<br />

in Figure 29-9 is a valid instantiation of the Class diagram in Figure 29-8 and has the<br />

same data and structure as this XML document.<br />

:User<br />

name="Victor Peters"<br />

loginName="victorpeters"<br />

password="sreteprotciv"<br />

:Appointment<br />

dateAndTime="1011384689352"<br />

description="Meeting with business..."<br />

priority="medium"<br />

:Contact<br />

name="Kermit T. Frog"<br />

eMail="frog@kermit.com"<br />

notes="Client wants pig detection system"<br />

:Contact<br />

name="<strong>To</strong>m Pender"<br />

eMail="tom@pender.com"<br />

notes="Business Analyst and Designer"<br />

Figure 29-9 <strong>UML</strong> Object diagram<br />

The Object diagram in Figure 29-9 maps to the XML document in Listing 29-1. The User<br />

object becomes the element. That element contains one sub-element for each<br />

attribute of the user class. Each attribute, like , has the value of the attribute<br />

followed by an end tag . The link from User to Appointment is shown as a<br />

sub-element of the element and contains all the attributes in the Appointment<br />

class. Notice that the dateAndTime (stored in Java milliseconds format) and priority are<br />

attributes instead of being separate elements because they are simple values.<br />

Listing 29-1<br />

XML for the Appointments Object diagram<br />

<br />

Victor Peters<br />

victorpeters<br />

sreteprotciv<br />

<br />

<br />

Meeting with business analyst and client<br />

<br />

<br />

<br />

Kermit T. Frog<br />

frog@kermit.com<br />

Client wants pig detection system<br />

<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!