⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib0041.html

📁 java外企软件工程师就业班 J2EE方向 《J2EE架构师手册》 电子书
💻 HTML
字号:
<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Determining Relationships</title>
<link rel="STYLESHEET" type="text/css" href="images/xpolecat.css">
<link rel="STYLESHEET" type="text/css" href="images/ie.content.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle"  alt="Team LiB"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="LiB0040.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0042.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr></table>
<br>
<div class="chapter">
<a name="ch06"></a>
<div class="section">
<h2 class="first-section-title"><a name="195"></a><a name="ch06lev1sec3"></a>Determining Relationships</h2><p class="first-para">A <b class="bold">relationship</b> describes how different classes interact. You can determine relationships after you've identified individual classes. The UML literature documents several categories of object relationships. Most applications only need the four types described in the following paragraphs.</p>
<p class="para">
<b class="bold">Dependency (uses) relationship</b> documents that one class uses another class. At a code level, <i class="emphasis">using</i> another class means referencing the class in some way (e.g., declaring, instantiating, etc.). Because this relationship type is strikingly similar to the association relationship type, I usually ignore the difference between the two types as unnecessary complexity. The relationship in <a class="internaljump" href="#ch06fig01">figure 6.1</a> is read as "<span class="fixed">Customer uses Account</span>."</p>
<div class="figure">
<a name="196"></a><a name="ch06fig01"></a><span class="figuremediaobject"><img src="images/fig92_01.jpg" height="82" width="309" alt="" border="0"></span>
<br style="line-height: 1">
<span class="figure-title"><span class="figure-titlelabel">Figure 6.1: </span>Dependency Relationship Illustration</span>
</div>
<a name="197"></a><a name="IDX-76"></a>
<p class="para">
<b class="bold">Generalizes (extends) relationship</b> documents that one class extends, or inherits the characteristics of, another class. Most medium to large applications have a handful of this type of relationship.</p>
<p class="para">An extends relationship is denoted by a solid line with a hollow arrow. The relationship in <a class="internaljump" href="#ch06fig02">figure 6.2</a> is read as "<span class="fixed">TrustCustomer extends Customer.</span>" The attributes of Customer will be available and usable in all children.</p>
<div class="figure">
<a name="198"></a><a name="ch06fig02"></a><span class="figuremediaobject"><a href="images/fig92%5F02%5F0%2Ejpg" NAME="IMG_13" target="_parent"><img src="images/fig92_02.jpg" height="124" width="350" alt="Click To expand" border="0"></a></span>
<br style="line-height: 1">
<span class="figure-title"><span class="figure-titlelabel">Figure 6.2: </span>Extends Relationship Illustration</span>
</div>
<p class="para">
<b class="bold">Realization (implements) relationship</b> documents that a class implements an interface. An implements relationship is denoted by a dotted line with a hollow arrow. The relationship in <a class="internaljump" href="#ch06fig03">figure 6.3</a> is read as "<span class="fixed">EmailDelivery</span> implements <span class="fixed">ReportDeliveryType</span>."</p>
<div class="figure">
<a name="199"></a><a name="ch06fig03"></a><span class="figuremediaobject"><a href="images/fig93%5F01%5F0%2Ejpg" NAME="IMG_14" target="_parent"><img src="images/fig93_01.jpg" height="148" width="254" alt="Click To expand" border="0"></a></span>
<br style="line-height: 1">
<span class="figure-title"><span class="figure-titlelabel">Figure 6.3: </span>Implements Relationship Illustration</span>
</div>
<a name="200"></a><a name="IDX-77"></a>
<p class="para">
<b class="bold">Aggregation (collects) relationship</b> documents that a class collects multiple occurrences of a class. A collects relationship is denoted by a solid line with a diamond next to the class doing the collecting. The relationship in <a class="internaljump" href="#ch06fig04">figure 6.4</a> reads "<span class="fixed">Customer</span> collects <span class="fixed">Account</span>."</p>
<div class="figure">
<a name="201"></a><a name="ch06fig04"></a><span class="figuremediaobject"><img src="images/fig93_02.jpg" height="239" width="134" alt="" border="0"></span>
<br style="line-height: 1">
<span class="figure-title"><span class="figure-titlelabel">Figure 6.4: </span>Collects Relationship Illustration</span>
</div>
<p class="last-para">
<b class="bold">Don't document formal relationships to value objects.</b> VOs have so many relationships that if they are documented, the model becomes unreadable and unusable. After all, the purpose of creating the class diagram is to make the application easier for the team to understand and implement. VO relationships are easy for developers to figure out from the method signatures anyway.</p>
</div>
</div><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle"  alt="Team LiB"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="LiB0040.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0042.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr></table>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -