《uml与面向对象系统分析与设计.ppt》由会员分享,可在线阅读,更多相关《uml与面向对象系统分析与设计.ppt(37页珍藏版)》请在三一办公上搜索。
1、249,概念 设计:服务与UML 场景图,250,对象 责任Responsibilities,属性-“我知道什么”关系-“我知道的其他类和对象”服务-“我能作什么”,251,Operations服务,同义词:方法,功能&操作定义:Actions performed to fulfill the purpose of the information system and meet the needs of the user.满足信息系统的目的和用户需要的活动是对一个事件的响应:外部事件-商业活动内部事件-为完成目的而进行的消息传送,252,服务的类型,基本Basic-默认的创建一个对象搜索一个对
2、象获取和设置属性值建立或取消对象关联对象删除问题域 specific to the domain being studied,253,模版,类名,操作,属性,类名,1)基本操作2)问题域方法-继承-自定,属性-继承-自定,考虑,254,问题域服务例子,学生,课程登记课程改修请求成绩单交费etc.,studentIDNumberstudentNameetc.,下一个.基本服务例子.,255,NEW 操作例子,Student,attributes,operations,Student 1,Student 2,Student 3,Student,attributes,operations,Stude
3、nt 1,Student 2,Student 3,Student 4,new Student,原来,后来,Note:All basic operation examples are for illustrationonly as each implementation language handles them differently,256,SEARCH 操作例子#1,学生,attributes,operations,学生1,学生2,学生3,searchStudent,studentIDNumber=123-45-6789,Student,attributes,operations,学生 1
4、,学生2,学生3,StudentIDNumber:123-45-6789,257,SEARCH 操作例子#2,Student,attributes,operations,Student 1,Student 2,Student 3,searchStudent,studentName=“Smith”,Student 1,Student 2,Student 3,StudentName:Smith,Mary,StudentName:Smith,John,Student,attributes,operations,258,GET 操作例子,Student,attributes,operations,St
5、udent 1,Student 2,Student 3,telephone:(619)588-3296,getStudent=“Student2”,telephoneresult:telephone=(619)588-3296,259,SET 操作例子,Student,attributes,operations,Student 1,Student 2,Student 3,setStudent,telephone,(619)594-3736,telephone:(619)588-3296,Student,attributes,operations,Student 1,Student 2,Stud
6、ent 3,telephone:(619)594-3736,before,after,260,CONNECT 操作例子,StudentClub,attributes,operations,ACM Club,Beta Sigma Pi Club,AITP Club,connectStudentClub=AITP Club,ClubMember=AITP-Student N,ClubMember,attributes,operations,ACM-Student 1,ACM-Student N,BSP-Student 1,BSP-Student N,AITP-Student 1,AITP-Stud
7、ent N,261,DISCONNECT 操作例子,StudentClub,attributes,operations,ACM Club,Beta Sigma Pi Club,AITP Club,disconnectStudentClub=AITP Club,ClubMember=AITP-Student N,ClubMember,attributes,operations,ACM-Student 1,ACM-Student N,BSP-Student 1,BSP-Student N,AITP-Student 1,AITP-Student N,262,DELETE 操作例子,Student,a
8、ttributes,operations,Student 1,Student 2,Student 3,Student,attributes,operations,Student 1,Student 3,deleteStudent 2,before,after,263,问题域服务,“问题域服务形形色色”是问题域和其中定义的类独有的应该遵从前面讨论的处理复杂性的信息包装原则对外部事件的反应.对内部事件的反应.通过UML和其它技术来描述服务,264,问题域服务例子#1,车,起点终点,计算行程,计算行程VIN=12345,totalMiles,VIN:12345 17,489 17,924,计算行程,
9、总行程=终点-起点,(sample):435=17,924-17,489,265,问题域服务例子#2,车,出租费,欠销售税,欠销售税VIN=12345,taxRate,totalTax,VIN:12345$279.00,salesTaxOwed,总税额=出租费X 税率,(sample):$21.62=279.00 X.0775,266,问题域服务例子#3,报表,车辆过期报表等,向汽车的“检查归还日期”服务发送信息,汽车,规定归还日期,检查归还日期,检查归还日期车辆清单,检查返还日,FOR EACH 辆车 IF 归还日期 早于今天 把车辆信息送入 过期车辆报表EndifEnd For Each,
10、(sample):VIN:12345规定归还日:05/05/95今天:04/30/95过期:NoVIN:12654规定归还日:04/28/95今天日期:04/30/95过期:Yes(will be on report)etc.,267,封装和重用服务例子,Student,addCourse,注:addCourse 服务为完成目的请求其它对象的服务(有一些是本身对象所有的有一些是信息系统内其它对象的).,SomeOtherClass(es),输入学号验证学生身份输入课程号验证本学期是否有开该课程是否有多余名额检查学生是否符合课程条件在课程中加入该生名,addCourse 对外部事件作出响应;其它
11、对内部事件的响应,268,服务的发现和标识,标识事件和相关服务标识类的状态标识要求的信息说明服务的细节,269,Describing Operation Details,UML Sequence Diagram(场景图)UML Collaboration Diagram(协作图)UML State Diagram(状态转移图)UML Activity Diagram(活动图)Structured English or Pseudocode(结构化英语或伪代码)决策表或决策树,270,UML 状态转换图,UML 状态图模板,状态 1,状态2,状态3,状态n,条件行动,(note:每一个箭头都要被
12、标作 条件 行动),271,UML 状态转换图例,电话自动应答机例子,空闲,记录输出信息,回话,记录消息,倒带,放送消息,按下记录键,电话响,呼叫者讲话,到头,按下放送消息按钮,272,UML 状态转换图例#2,飞机售票机,座位,20.350,1,有票,锁住状态,无票,lock,timed out,unlock,sold,273,UML时序图,是对象交互的特定时序也称为场景图图形上用X轴列出对象,Y轴表示消息顺序.,new()prepare()prepare()check()if check()true remove()needToReorder()if needToReorder()true
13、 new()endif new()endif,275,例子的类,输入窗口,定货,定单项,库存项,预购,发送,交付界面,问题域,new()etc,prepare()etc,prepare()etc,check()remove()needToReorder()etc,new()etc,new()etc,276,UML 协作图,是一种强调对象接收与发送信息的结构化组织的交互图表对象作为顶点,消息为弧;数字表示顺序,277,UML 协作图,场景图与协作图可互换,协作图,278,UML 活动图,显示一个活动到另一个活动的流.把类、接口等串接在一起类似 DFD图当系统行为异常复杂时使用,UML 活动图例子
14、,Adapted from:Rumbaugh,J,Jacobson,I.and Booch,G.,The Unified Modeling Language Reference Guide,Addison-Wesley,1999,p.32,280,For each Automobile If scheduledReturnDate less than Today send vehicle information message to overdueVehicleReport EndifEnd For Each,结构化英语,Automobile,checkReturnDate,checkRetu
15、rnDate operation Structured English,scheduledReturnDate,Note:有时称为伪代码,281,判定表,规则,条件,行动,1.2.3.4.5.etc.,1.2.3.etc.,1.2.3.4.5.6.7.8.etc.,判定表模板,282,判定表1,规则,条件,活动,Percent=90%89%=Percent=80%79%=Percent=70%69%=Percent=60%59%=Percent,Grade=AGrade=BGrade=CGrade=DGrade=F,1 2 3 4 5,YX,YX,YX,YX,YX,要考虑是否条件已经覆盖所有情
16、况?,283,决策树,决策树模版,condition 1,rule 1rule 2rule n,condition 2condition 2condition 2,rule 1rule 2rule nrule 1rule 2rule nrule 1rule 2rule n,condition ncondition ncondition ncondition ncondition ncondition ncondition ncondition ncondition n,rule 1rule 2rule n,rule 1rule 2rule n,rule 1rule 2rule n,rule 1
17、rule 2rule n,rule 1rule 2rule n,rule 1rule 2rule n,rule 1rule 2rule n,rule 1rule 2rule n,rule 1rule 2rule n,action(s)action(s)action(s),action(s)action(s)action(s),action(s)action(s)action(s),action(s)action(s)action(s),action(s)action(s)action(s),action(s)action(s)action(s),action(s)action(s)action(s),action(s)action(s)action(s),action(s)action(s)action(s),284,决策树例子,Percent=90%?,Yes,Grade=A,No,89%=Percent=80%?,Yes,Grade=B,No,79%=Percent=70%?,Yes,Grade=C,No,Etc.,Do the conditions cover all possible cases?,285,