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

📄 index.html

📁 《Big C++ 》Third Edition电子书和代码全集-Part1
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!--	-*-html-*-
	$Source: /usr/local/cvsroot/BigC++/25/index.html,v $
	$Revision: 1.3 $

	Big C++, chptr 25
	Kurt Schmidt, kschmidt@cs.drexel.edu

	NOTES
	- editor: cols=80, tabstop=2
	- 3 spaces are used for each indent in examples

	REVISIONS:
		$Log: index.html,v $
		Revision 1.3  2004/04/20 22:03:03  kurt
		Made slides smaller (view %150, on 1024x768 display)
		
		Revision 1.2  2004/02/16 19:47:57  kurt
		spelling
		
		Revision 1.1  2004/02/16 19:44:52  kurt
		Creation
		
-->

<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<script language="JavaScript" src="./config.js"></script>
	<script language="JavaScript" src="./pageFormat.js"></script>
	<script><!-- // Set title on page
		title()
	//--></script>
</head>

<body>

<hr><h2><font color="#009999" size="+3">Chapter 25 - The Unified Modeling
	Language</font></h2>
<font size="+1">

<script><!-- 
	image( "cover.png" )
//--></script>


</font>

<hr><h2><font color="#009999" size="+2">Chapter Goals</font></h2>
</font>
<hr noshade size="4" color="#009999">
<font size="+1">

<ul>
	<li>To continue the exploration of the UML</li>
	<li>To understand the creation and application of cases</li>
	<li>To learn how to create and use the various diagram types in the UML</li>
	<li>To understand how sequence diagrams help document the dynamic
		relationships between classes</li>
</ul>

</font>

<hr><h2><font color="#009999">25.1 Graphical Notation</font></h2>
<font size="+1">

<ul>
	<li>Convey design information</li>
	<li>Relationship information easily extracted</li>
	<li>The following scale better than flowcharts:
		<ul>
			<li>Object diagrams (chptr. 10)</li>
			<li>Class diagrams (chptr. 11)</li>
			<li>CRC cards (chptr. 13)</li>
		</ul>
	</li>
	<li>To follow:  wider variety of class, sequence, and state diagrams, and
		<i>use cases</i></li>
</ul>

</font>

<hr><h2><font color="#009999">25.2 Use Cases</font></h2>
<font size="+1">

<ul>
	<li>Describe how a system should work</li>
	<li>Each case:
		<ul>
			<li>Focuses on a specific scenario</li>
			<li>Describes steps to completion</li>
		</ul>
	</li>
	<li>Each step represents an interaction between an outside entity
		(<i>actor</i>) and the system</li>
	<li>Use case must complete to a point that is of some value</li>
</ul>

</font>

<hr><h2><font color="#009999">25.2 Use Cases</font></h2>
<font size="+1">

<p>E.g., a voice mail system:

<ul>
	<li>"Leave a message" - steps a caller (the actor) must take
		<ul>
			<li>Value:  actor deposits a message</li>
		</ul>
	</li>
	<li>"Retrieve messages" - steps the mailbox owner must take
		<ul>
			<li>Value:  actor retrieves his messages</li>
		</ul>
	</li>
</ul>

</font>

<hr><h2><font color="#009999">25.2 Use Cases</font></h2>
<font size="+1">

<ul>
	<li>A use case should have:
		<ul>
			<li>Descriptive name</li>
			<li>Main sequence of actions</li>
			<li>Variants
				<ul>
					<li>Description of possible failures</li>
				</ul>
			</li>
		</ul>
	</li>
	<li>Can be made simple or formal</li>
</ul>
</font>

<hr><h2><font color="#009999">25.2 Use Cases - E.g.</font></h2>
<font size="+1">

<h3>Leave a Message:</h3>
<ol>
	<li>Caller dials mail system</li>
	<li>System prompts for mailbox:<br>
		<tt>Enter mailbox #</tt>
	</li>
	<li>Caller enters recipient's extension</li>
	<li>System prompts for message:<br>
		<tt>Leave message for xxx</tt>
	</li>
	<li>Caller speaks message</li>
	<li>Caller hangs up</li>
	<li>System stores message in recipient's mailbox</li>
</ol>

</font>

<hr><h2><font color="#009999">25.2 Use Cases - E.g. (cont.)</font></h2>
<font size="+1">

<h4>Variation #1:</h4>
<table>
	<tr>
		<td valign='top' width="10%">1.1</td>
		<td>User enters invalid extension (Step 3)</td>
	</tr>
	<tr>
		<td valign='top'>1.2</td>
		<td>System responds<br>
			<tt>Invalid mailbox #</tt>
		</td>
	</tr>
	<td valign='top'>1.3</td>
	<td>Continue with Step 2</td>
</table>

<h4>Variation #2:</h4>
<table>
	<tr>
		<td valign='top' width="10%">2.1</td>
		<td>Caller doesn't leave a message (after Step 4)</td>
	</tr>
	<tr>
		<td valign='top' width="10%">2.2</td>
		<td>System discards empty message</td>
	</tr>
</table>

</font>

<hr><h2><font color="#009999">25.3 UML Class Diagrams</font></h2>
<font size="+1">

<ul>
	<li>Static</li>
	<li>Describe class relationships</li>
	<li>Classes drawn as boxes</li>
	<li>Appropriate attributes and methods in additional compartments:
		<script><!-- 
			image( "fig01.png" )
		//--></script>
	</li>
</ul>

</font>

<hr><h2><font color="#009999">25.3 UML Class Diagrams (cont.)</font></h2>
<font size="+1">

<ul>
	<li>Important attributes and methods are listed</li>
	<li>Type of attributes and parameters can be specified <nobr><i>attribute</i>
		: <i>Type</i></nobr><br>
		<blockquote><tt>
				text : string
		</tt></blockquote>
	</li>
	<li>Similarly for return type of methods:
		<blockquote><tt>
			get_message(index : int) : Message
		</tt></blockquote>
	</li>
	<li>Types often omitted for attributes, <i>parameters</i>, and return
		values</li>
</ul>

</font>

<hr><h2><font color="#009999">25.3 UML Class Diagrams (cont.)</font></h2>
<font size="+1">

<table cellpadding='5'>
	<tr>
		<td width='40%'><font size='+1'>
			<ul>
				<li>Links (connectors) for class diagrams:</li>
			</ul>
		</font>
		</td>
		<td align='left'>
			<script><!-- 
				image( "fig02.png" )
			//--></script>
		</td>
	</tr>
</table>

</font>

<hr><h2><font color="#009999">25.3 UML Class Diagrams (cont.)</font></h2>
<font size="+1">

<ul>
	<li>Denote multiplicity at the endpts. of the aggregation connector</li>
	<li>Common notations:
		<table>
			<tr><td width="40%"><tt>*</tt></td>
				<td>zero or more</td></tr>
			<tr><td><tt>1..*</tt></td>
				<td>one or more</td></tr>
			<tr><td><tt>0..1</tt></td>
				<td>zero or one</td></tr>
			<tr><td><tt>1</tt></td>
				<td>exactly one</td></tr>
		</table>
	</li>
</ul>

</font>

<hr><h2><font color="#009999">25.3 UML Class Diagrams (cont.)</font></h2>
<font size="+1">

<script><!-- 
	image( "fig03.png" )
//--></script>

<ul>
	<li>Enclosing class contains arrow tip</li>
	<li>A queue may have 0 or more messages</li>
	<li>A message will be on exactly one queue</li>
</ul>

</font>

<hr><h2><font color="#009999">25.3 UML Class Diagrams (cont.)</font></h2>
<font size="+1">

<ul>
	<li><i>Composition</i> - stronger form of aggregation</li>
	<li>Contained objects do not exist independently</li>
	<li>A solid diamond is used</li>
	<li>A message queue is permanently contained in a mailbox:
		<script><!-- 
			image( "fig04.png" )
		//--></script>
	</li>
	<li>But messages are not specific to a given queue</li>
</ul>

</font>

<hr><h2><font color="#009999">25.3 UML Class Diagrams (cont.)</font></h2>
<font size="+1">

<ul>
	<li>An <i>association</i> is a more general relationship</li>
	<li>Used early in the design</li>
	<li>Solid line w/no diamond</li>
	<li><i>Roles</i> can be written at the ends of the lines:
		<script><!-- 
			image( "fig05.png" )
		//--></script>
	</li>
	<li>Students register for courses, courses have students</li>
	<li>Bidirectional</li>
</ul>

</font>

<hr><h2><font color="#009999">25.3 UML Class Diagrams (cont.)</font></h2>
<font size="+1">

<ul>
	<li>Associations are often directed</li>
	<li>E.g., messages know nothing about the containing queue:
		<script><!-- 
			image( "fig06.png" )
		//--></script>
	</li>
	<li>Use open arrow</li>
	<li>Try to minimize dependencies</li>
</ul>

</font>

<hr><h2><font color="#009999">25.4 Sequence Diagrams</font></h2>
<font size="+1">

<ul>
	<li>Show dynamics of a scenario</li>
	<li>Describe communications among objects</li>
	<li>Most commonly illustrates the behavior of a single method</li>
</ul>

</font>

<hr><h2><font color="#009999">25.4 Sequence Diagrams (cont.)</font></h2>
<font size="+1">

<ul>
	<li>E.g., adding a message to a mailbox.  The mailbox adds it to its
		new-message queue:
		<blockquote><tt>new_messages.add(...)</tt></blockquote>
		<script><!-- 
			image( "fig07.png" )
		//--></script>
	</li>
</ul>

</font>

<hr><h2><font color="#009999">25.4 Sequence Diagrams (cont.)</font></h2>
<font size="+1">

<ul>
	<li>Objects are boxes w/underlined text</li>
	<li>Text might be:
		<ul>
			<li><tt>object_name : ClassName</tt></li>
			<li><tt>object_name</tt></li>
			<li><tt>: ClassName</tt></li>
		</ul>
	</li>
	<li>Dashed vertical line is the <i>lifeline</i></li>
		<ul>
			<li>Used to sequence events</li>
		</ul>
	</li>
	<li>Rectangles are <i>activation bars</i></li>
		<ul>
			<li>Object is executing a method (or waiting)</li>
		</ul>
	</li>
	<li>Arguments are not listed</li>
</ul>

</font>

<hr><h2><font color="#009999">25.4 Sequence Diagrams (cont.)</font></h2>
<font size="+1">

<table cellpadding='5'>
	<tr>
		<td width='40%'><font size='+1'>
			<ul>
				<li>A method called on the same object:</li>
			</ul>
		</font>
		</td>
		<td align='left'>
			<script><!-- 
				image( "fig08.png" )
			//--></script>
		</td>
	</tr>
</table>

</font>

<hr><h2><font color="#009999">25.4 Sequence Diagrams (cont.)</font></h2>
<font size="+1">

<ul>
	<li>Use <tt>&lt;&lt;create&gt;&gt;</tt> to denote the creation of a
		heap object:
		<script><!-- 
			image( "fig09.png" )
		//--></script>
	</li>
</ul>

</font>

<hr><h2><font color="#009999">25.4 Sequence Diagrams (cont.)</font></h2>
<font size="+1">

<ul>
	<li>Omit a large amount of detail</li>
	<li>Generally omit branches and loops (though notation is defined)</li>
	<li>Just show the principal objects and order of calls</li>
	<li>Can document complex interactions</li>
		<ul>
			<li>Common when a limited object collaborates w/several others</li>
		</ul>
	</li>
</ul>

</font>

⌨️ 快捷键说明

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