设计CheckingAccount类withdraw()操作的操作规约
用例名: withdraw
触发:withdraw
输入参数: nWithdraw : int
输出返回值: boolean
前置条件: nWithdraw <= nCurrentBalance
出现的前置条件/异常: exInsuffientFunds
描述/转换: nCurrentBalance = nCurrentBalance - nWithdraw
后置条件: nCurrentBalance < priorCurrentBalance
后置条件异常: exIncorrectBalance
基本/乐观场景 :见WithdrawFromCheckingAccount 顺序图
替代性场景/悲观场景:见WithdrawFromCheckingAccount
活动图
业务规则:ValidAccountRule, AdequateBalanceRule
设计异常类(exception classes)异常超类(操作:Exception()/Exception(string);异常子类:exInsufiicientFunds
[操作 :exInsufiicientFunds()、exInsufiicientFunds(string)];exIncorrectBalance[操作:exIncorrectBalance()、exIncorrectBalance(string)]。
设计 CheckingAccount 类的状态图
实施模型(Implementation
Models)
实施模型
设计过程环境
实施组件图
实施文件(Implementation Files):
TellerGUI.exe, BankApp.exe, BankDB.exe
组件接口选择:
1) BankApp具有单接口 IbankApp,其所有操作都是公有的(exposed)
2) BankApp暴露(exposes) IBankApp, ICheckingAccount, &
ISavingAccount 接口
3) BankApp暴露(exposes) IBankApp, IWithdraw, IDeposit,
ICheckingAccount, & ISavingAccount 接口
CORBA IDL/C++ 需要对接口进行描述
Rose 组件图:在浏览器窗口,选择Component View;,将"Main"重命名为"Component
View";双击图名显示该图;在图上放置组件和依赖关系(从client组件到supplier组件拖曳);在浏览器中把每个类拖到相应的组件中;选择Tools-Check
Model;选择File-Save.
实施部署图
Rose 部署图:在浏览器窗口选择Deployment
View;双击以显示该图;在图上放置节点和关系;选择Tools-Check
Model;选择File-Save.
//Sample IDL Interface Code(IDL 接口代码样本)
module BankApp {
interface IBankApp {
exception exInsuffientFunds;
IBankApp getApp();
boolean depositToCheckingAccount (in string sAcctNum, in int nDeposit) ;
boolean depositToSavingAccount (in string sAcctNum, in int nDeposit) ;
boolean withdrawFromCheckingAccount (in string sAcctNum, in int nWithdraw)raises
(exInsuffientFunds);
boolean withdrawFromSavingAccount (in string sAcctNum, in int nWithdraw) raises
(exInsuffientFunds);
};};
//Sample Java Interface Code Using Remote Method Invocation
//(使用RMI 的Java接口样本)
import java.rmi.*;
package BankApp;
public interface IBankApp extends java.rmi.Remote {
boolean depositToCheckingAccount (String sAcctNum, int nDeposit) throws
java.rmi.RemoteException ;
boolean depositToSavingAccount (String sAcctNum, int nDeposit) throws
java.rmi.RemoteException ;
boolean withdrawFromCheckingAccount (String sAcctNum, int nWithdraw) throws
java.rmi.RemoteException;
boolean withdrawFromSavingAccount (String sAcctNum, int nWithdraw) throws
java.rmi.RemoteException;
}
//Sample Microsoft IDL Interface Code for COM - Simplified
//(Microsoft IDL 的COM接口编码样本-简化版)
library BankAppLib {
dispinterface IBankApp {
IBankApp getApp();
boolean depositToCheckingAccount (BSTR sAcctNum, int nDeposit) ;
boolean depositToSavingAccount (BSTR sAcctNum, int nDeposit) ;
boolean withdrawFromCheckingAccount (BSTR sAcctNum, int nWithdraw);
boolean withdrawFromSavingAccount (BSTR sAcctNum, int nWithdraw);
};
coclass BankApp {
dispinterface IBankApp;
}; };
//Sample SOAP (Simple Object Access Protocol) SDL (Service Description Language)
with XML -Incomplete
//包含XML 的SOAP SDL样本-不完全
<?xml version='1.0'?>
<serviceDescription name='BankApp'
xmlns='urn:schemas-xmlsoap-org:sdl.2000-01-25'
xmlns:dt='http://www.w3.org/1999/XMLSchema'
xmlns:IBankApp='IBankApp'>
<import namespace='IBankApp' location='#IBankApp'/>
<soap xmlns='urn:schemas-xmlsoap-org:soap-sdl-2000-01-25'>
<interface name='IBankApp'>
<requestResponse name='WithdrawFromCheckingAccount'>
<request ref='IBankApp:WithdrawFromCheckingAccount'/>
<response ref='IBankApp:WithdrawFromCheckingAccountResponse'/>
</requestResponse>
</interface>
<service>
<addresses>
<address uri='http://myserver/IBankApp.asp'/>
</addresses>
<implements name='IBankApp'/>
</service>
</soap>
<IBankApp:schema id='IBankApp' targetNamespace='IBankApp'
xmlns='http://www.w3.org/1999/XMLSchema'>
<element name='WithdrawFromCheckingAccount'>
</element>
<element name='WithdrawFromCheckingAccountResponse'>
<type>
<element name='return' type='dt:boolean'/>
</type>
</element>
</IBankApp:schema>
</serviceDescription>
|
构建
编码/命名标准;接口代码-CORBA IDL;C++代码;CASE
工具脚本/定制报告的VBA /代码生成
Rose代码生成-需要Rose 专业版或企业版. 见Help Topic
Code Generation(帮助主题-Code Generation)。
步骤:
1 - 检查模型;
2 - 创建组件;
3 - 映射/分配类到组件;
4 - 设定代码生成特性;
5 - 选择一个类、组件或包
6 - 生成代码;
7 - 检查生成的代码。
Rose 逆工程-需要Rose 专业版或企业版. 见Help Topic-
Reverse Engineering. 使用模型更新工具(Model Update Tool)。
测试
整个系统/集成测试-所有组件/子系统;组件测试-每个组件;单元测试-每个类。
测试实例规约:
测试实例名(Test Use Case Name):
用例名(Use Case Name):
用例场景名(Use Case Scenario Name):
触发器(Trigger):
输入参数(Input Parameters):
输出返回值(Output Return):
前置条件(Precondition):
出现的前置条件异常(Precondition Exception Raised):
描述/转换(Description/Transformation):
后置条件(Postcondition):
后置条件异常(Postcondition Exception):
注释(Comments):
VII - 建模和构造其他组件
TellerGUI Forms(表单);BankDB Tables(表): tblWithdraw,
tblDeposit, tblSavingAccount, tblCheckingAccount
翻译说明
1. CASE
:计算机辅助软件工程,以下直接使用英文缩写。
2. test case :在软件工程中一般翻译为"测试用例",为了跟use
case(用例)相区别,本译文用"测试实例"替换
3. harness: 在《面向对象系统的测试》(Robert V.Binder
著 华庆一等著)中译为"测试装置",是指由测试驱动器和其他支持测试执行的工具组成的系统(如桩、测试实例、测试驱动器等)
参考文献
1.《UML参考手册》 James Rumbaugh,Ivar
Jacobson,Grady Booch 著,姚淑珍,唐发根等译)
2.《统一软件开发过程》 Ivar Jacobson,Grady Booch ,James
Rumbaugh 著,周伯生、冯学民、樊东平译。
上一页 下一页 |