📄 index.html
字号:
</font>
<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
</font></h2>
<font size="+1">
<table cellpadding="3">
<tr>
<td>
<script><!--
image( "un06.png" )
//--></script>
</td>
<td>
<script><!--
image( "un07.png" )
//--></script>
</td>
</tr>
<tr>
<td>
<script><!--
image( "un08.png" )
//--></script>
</td>
<td>
<script><!--
image( "un09.png" )
//--></script>
</td>
</tr>
</table>
</font>
<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
</font></h2>
<font size="+1">
<h3><b>Retrieve Messages</b> use case</h3>
<p>First few steps same as preceding.
<ol>
<li>User types passcode
<ul>
<li><tt>Telephone</tt> notifies <tt>Connection</tt></li>
</ul>
</li>
<li><tt>Connection</tt> asks <tt>Mailbox</tt> to check passcode
<ul>
<li>Add "manage passcode" responsibility to <tt>Mailbox</tt></li>
</ul>
</li>
<li>If passcode valid:
<ul>
<li><tt>Connection</tt> sets the <tt>Mailbox</tt> as current</li>
<li>asks <tt>Telephone</tt> to speak mailbox menu</li>
</ul>
</li>
</ol>
</font>
<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
</font></h2>
<font size="+1">
<h3><b>Retrieve Messages</b> use case (cont.)</h3>
<ol start="4">
<li>User chooses "retrieve msgs" option
<ul>
<li><tt>Telephone</tt> passes it on to <tt>Connection</tt></li>
</ul>
</li>
<li><tt>Connection</tt> asks <tt>Telephone</tt> to speak msg menu</li>
<li>User types in the "listen to current message" option
<ul>
<li><tt>Telephone</tt> passes it on to the <tt>Connection</tt></li>
</ul>
</li>
<li><tt>Connection</tt> gets first <tt>Message</tt> from current
<tt>Mailbox</tt>
<ul>
<li>sends its contents to the <tt>Telephone</tt></li>
<li>Add "retrieve messages" responsibility to Mailbox)</li>
</ul>
</li>
</ol>
</font>
<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
</font></h2>
<font size="+1">
<h3><b>Retrieve Messages</b> use case (cont.)</h3>
<ol start="8">
<li><tt>Connection</tt> asks the <tt>Telephone</tt> to speak the message
menu</li>
<li>User types in "save current message" option</li>
<ul>
<li>The <tt>Telephone</tt> passes it on to the <tt>Connection</tt></li>
</ul>
</li>
<li><tt>Connection</tt> tells the <tt>Mailbox</tt> to save current msg
<ul>
<li>Modify the responsibilities of <tt>Mailbox</tt> to retrieve, save,
delete messages)</li>
</ul>
</li>
<li>The <tt>Connection</tt> asks the <tt>Telephone</tt> to speak the
message menu</li>
</ol>
</font>
<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
</font></h2>
<font size="+1">
<table>
<tr>
<td valign="top">
<ul>
<li>The updated <tt>Mailbox</tt> CRC:</li>
<li>Remaining use cases do not add new information, hence, omitted</li>
</ul>
</td>
<td width="450">
<script><!--
image( "un10.png" )
//--></script>
</td>
</tr>
</table>
</font>
<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
</font></h2>
<font size="+1">
<ul>
<li>High level reasoning is difficult</li>
<li>Easily-implemented operations vs. those that appear easy</li>
<li><strong>Practice</strong></li>
<li>Many false starts and detours</li>
<li>Redesign until system works</li>
<li>CRC cards are meant to fail <i>early</i>, <i>often</i>, and
<i>inexpensively</i></li>
<li>Plan to trash your first design</li>
<li><strong>Practice</strong></li>
</ul>
</font>
<hr><h2><font color="#009999">25.6.3 UML Class Diagrams for the Voice Mail
System</font></h2>
<font size="+1">
<ul>
<li>Collaboration parts of the CRC cards show dependencies:
<ul>
<li><tt>Mailbox</tt> depends on <tt>MessageQueue</tt></li>
<li><tt>MailSystem</tt> depends on <tt>Mailbox</tt></li>
<li><tt>Connection</tt> depends on <tt>Telephone</tt>,
<tt>MailSystem</tt>, <tt>Message</tt>, and <tt>Mailbox</tt></li>
<li><tt>Telephone</tt> depends on <tt>Connection</tt></li>
</ul>
</li>
</ul>
</font>
<hr><h2><font color="#009999">25.6.3 UML Class Diagrams for the Voice Mail
System</font></h2>
<font size="+1">
<script><!--
image( "fig11.png" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.3 UML Class Diagrams for the Voice Mail
System</font></h2>
<font size="+1">
<ul>
<li>Aggregation:
<ul>
<li>System has mailboxes</li>
<li>Mailbox has 2 msg queues</li>
<li>Queue has msgs (maybe)</li>
<li>A <tt>Connection</tt> has a current mailbox; also references to the
<tt>MailSystem</tt> and <tt>Telephone</tt> objects</li>
</ul>
</li>
<li>No inheritance</li>
<li>Note: aggregation implies dependency</li>
</ul>
</font>
<hr><h2><font color="#009999">25.6.3 UML Class Diagrams for the Voice Mail
System</font></h2>
<font size="+1">
<script><!--
image( "fig12.png" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.4 UML Sequence and State Diagrams</font></h2>
<font size="+1">
<ul>
<li>Understand complex control flow w/multiple objects</li>
<li><tt>Telephone</tt> reads input</li>
<li>Passes it to <tt>Connection</tt></li>
<li>Postulate 3 functions for <tt>Connection</tt>:
<ul>
<li><tt>dial</tt> - passes on button press</li>
<li><tt>record</tt> - passes on speech</li>
<li><tt>hangup</tt> - tells connection telephone has hung up</li>
</ul>
</li>
</ul
</font>
<hr><h2><font color="#009999">25.6.4 UML Sequence and State Diagrams (cont.)
</font></h2>
<font size="+1">
<h3><b>Leave a Message</b> sequence diagram</h3>
<script><!--
image( "fig13.png" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.4 UML Sequence and State Diagrams (cont.)
</font></h2>
<font size="+1">
<h3><b>Leave a Message</b> sequence diagram</h3>
<ol>
<li>Caller keys in extension (shown as single call to <tt>dial</tt>)</li>
<li><tt>Connection</tt> calls system's <tt>find_mailbox</tt></li>
<li>The <tt>Mailbox</tt> object on the right is returned</li>
<li>Connection invokes <tt>get_greeting</tt><br>
(greeting is passive; doesn't appear on diagram)</li>
<li>Connection plays appropriate greeting</li>
<li>Telephone reads msg from user, passes it to connection</li>
<li>Telephone reads hangup, passes it to connection</li>
<li>Connection constructs <tt>Message</tt>, adds it to mailbox</li>
</ol>
</font>
<hr><h2><font color="#009999">25.6.4 UML Sequence and State Diagrams (cont.)
</font></h2>
<font size="+1">
<h3><b>Retrieve a Message</b> sequence diagram</h3>
<script><!--
image( "fig14.png" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.4 UML Sequence and State Diagrams (cont.)
</font></h2>
<font size="+1">
<ul>
<li>System is not in control of input</li>
<li>Telephone notifies connection of any input event</li>
<li>E.g., connection is called 3 times during <b>Leave a Msg</b></li>
<li>The connection must keep track of states, to determine proper
action on given input</li>
<li>Next slide is the state diagram for the system</li>
</ul>
</font>
<hr><h2><font color="#009999">25.6.4 UML Sequence and State Diagrams (cont.)
</font></h2>
<font size="+1">
<script><!--
image( "fig15.png" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation</font></h2>
<font size="+1">
<ul>
<li>Following files can be downloaded and run</li>
<li>Enter <tt>Q</tt> to quit</li>
<li>Look at the classes</li>
<li>Compare documentation to the CRC cards and UML diagrams</li>
<li>Trace functions calls, compare to the sequence diagrams</li>
<li>Find the state transitions for <tt>Connection</tt></li>
<li>Only modify <tt>Telephone</tt> and <tt>MailSystemTest</tt> to add
a GUI (chptr 27)</li>
</ul>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation (<tt>message.h</tt>)
</font></h2>
<font size="+1">
<script><!--
iframeWrapCode( "message.h", "90%", "75%" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation (<tt>mailbox.h</tt>)
</font></h2>
<font size="+1">
<script><!--
iframeWrapCode( "mailbox.h", "95%", "75%" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation (<tt>mailbox.cpp</tt>)
</font></h2>
<font size="+1">
<script><!--
iframeWrapCode( "mailbox.cpp", "90%", "75%" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation (<tt>mailsystem.h</tt>)
</font></h2>
<font size="+1">
<script><!--
iframeWrapCode( "mailsystem.h", "90%", "75%" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation (<tt>mailsystem.cpp</tt>)
</font></h2>
<font size="+1">
<script><!--
iframeWrapCode( "mailsystem.cpp", "90%", "75%" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation (<tt>telephone.h</tt>)
</font></h2>
<font size="+1">
<script><!--
iframeWrapCode( "telephone.h", "90%", "75%" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation (<tt>telephone.cpp</tt>)
</font></h2>
<font size="+1">
<script><!--
iframeWrapCode( "telephone.cpp", "90%", "75%" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation (<tt>connection.h</tt>)
</font></h2>
<font size="+1">
<script><!--
iframeWrapCode( "connection.h", "90%", "75%" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation (<tt>connection.cpp</tt>)
</font></h2>
<font size="+1">
<script><!--
iframeWrapCode( "connection.cpp", "90%", "75%" )
//--></script>
</font>
<hr><h2><font color="#009999">25.6.5 Implementation
(<tt>mailsystemtest.cpp</tt>)</font></h2>
<font size="+1">
<script><!--
iframeWrapCode( "mailsystemtest.cpp", "90%", "65%" )
//--></script>
</font>
<hr><h2><font color="#009999">Chapter Summary</font></h2>
<font size="+1">
<hr color="#00ffff" size="6">
<ol>
<li>Graphical notations help convey design information</li>
<li>Use cases provide concrete scenarios from which general action can be
abstracted</li>
<li>Class diagrams record various relationships, including use, dependency,
and inheritance</li>
<li>Sequence diagrams record the dynamic interaction between objects</li>
<li>State diagrams are useful for documenting objects that change their
behavior during the course of execution according to their current
state</li>
</ol>
</font>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -