Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 1 OBJECT-ORIENTED ANALYSIS AND DESIGN

Similar presentations


Presentation on theme: "Chapter 1 OBJECT-ORIENTED ANALYSIS AND DESIGN"— Presentation transcript:

1 Chapter 1 OBJECT-ORIENTED ANALYSIS AND DESIGN

2 Objectives Describe the book goals and scope.
Define object-oriented analysis and design(OOA/D). Illustrate a brief OOA/D example. Overview UML and visual agile modeling.

3 1.1 What Will You Learn? Is it Useful?
1.2 The Most Important Learning Goal 1.3 What is Analysis and Design? 1.4 What is Object-Oriented Analysis and Design? 1.5 A Short Example 1.6 What is the UML? 1.7 Visual Modeling is a Good Thing 1.8 History

4 1.1 What Will You Learn? Is it Useful?
This book is a tool to help developers and students learn core skills in object-oriented analysis and design (OOA/D). These skills are essential for the creation of well-designed, robust, and maintainable software using OO technologies and languages such as Java or C#.

5 Figure 1.1 Topics and skills covered
OOA/D Patterns UML notation Topics and Skills Principles and guidelines Requirements analysis Iterative Development with An agile Unified Process Figure 1.1 Topics and skills covered

6 In conclusion, this book helps a student or developer:
Apply principles and patterns to create better object designs. Iteratively follow a set of common activities in analysis and design, based on an agile approach to the UP as an example. Create frequently used diagrams in the UML notation.

7 1.2 The Most Important Learning Goal
A critical,fundamental ability in OOA/D is to skillfully assign responsibilities to software components. 在面向对象分析与设计中最重要的能力是能够熟练地为软件构件分配职责。 本书中给出了9个用于对象设计和职责分配的基本原则。它们在学习帮助中被称作GRASP模式。

8 1.3 What is Analysis and Design?
Analysis emphasizes an investigation of the problem and requirements, rather than a solution. Design emphasizes a conceptual solution that fulfills the requirements, rather than its implementation.

9 1.4 What is Object-Oriented Analysis and Design?
During object-oriented analysis,there is an emphasis on finding and describing the objects--or concepts--in the problem domain. During object-oriented design, there is an emphasis on defining software objects and how they collaborate to fulfill the requirements.

10

11 Figure 1.2 Object-orientation emphasizes representation of objects
domain concept Book title visualization of domain concept public class Book { private String title; public Chapter getChapter(int) {…} } representation in an object-oriented programming language Figure 1.2 Object-orientation emphasizes representation of objects

12 图书馆信息系统 面向对象的分析/设计 结构化的分析/设计 按照对象或概念分解 按照功能或过程分解 System Catalog Librarian Book Borrower Record Loans Add Resource Report Fines

13 1.5 A Short Example Before diving into the details of requirements analysis and OOA/D, this section presents a birds-eye view of a few key steps and diagrams, using a simple example—a “dice game” in which a player rolls two die. If the total is seven, they win; otherwise, they lose.

14 Define use cases Define domain model Define interaction diagrams Define design Class diagrams

15 Define Use Cases Play a Dice Game
A player picks up and rolls the dice. If the dice face value total seven, they win; otherwise, they lose. Player Play a Dice Game

16 Define a Domain Model Object-oriented analysis is concerned with creating a description of the domain from the perspective of objects. There is an identification of the concepts, attributes, and associations that are considered noteworthy. The result can be expressed in a domain model that shows the noteworthy domain concepts or objects.

17 Figure 1.3 Partial domain model of the dice game
Player name Die faceValue Rolls 1 2 1 2 Plays 1 DiceGame 1 Includes Figure 1.3 Partial domain model of the dice game

18 Define Interaction Diagrams
Object-oriented design is concerned with defining software objects and their collaborations. Sequence diagram shows the flow of messages between software objects, and thus the invocation of methods.

19 Figure 1.4 Sequence diagram illustrating messages
:DiceGame die1:Die die2:Die play() roll() Player fv1:=getFaceValue() roll() Fv2:=getFaceValue() Figure 1.4 Sequence diagram illustrating messages between software objects

20 Define Design Class Diagrams
Design class diagram illustrates the attributes and methods of the classes.

21 Figure 1.5 Partial design class diagram
Die faceValue:int getFaceValue():int roll() DiceGame die1:Die die2:Die play() 1 2 Figure 1.5 Partial design class diagram

22 1.6 What is the UML? The Unified Modeling Language is a visual language for specifying, constructing and documenting the artifacts of systems .

23

24 概念类(conceptual class)—现实世界中的 概念或事物。在UP领域模型中包含概念 类。
软件类(software class)—表示软件构件在 规格说明或实现视点中的类。 实现类(implementation class)—特定OO 语言(如Java)中的类。

25 UML的九种图 用例图(Use Case Diagram) 类图(Class Diagram) 对象图(Object Diagram)
顺序图(Sequence Diagram) 协作图(Collaboration Diagram) 状态图(Statechart Diagram) 活动图(Activity Diagram) 组件图(Component Diagram) 部署图(Deployment Diagram)

26 上述九种图又可分为三个大类:静态图、动态图和结构图。
静态图:描述系统的结构和功能,包括用例图、类图和对象图; 动态图:描述系统支持的对象间相互作用的关系,包括顺序图、协作图、状态图和活动图; 结构图:把系统的实现描述成可执行的组件或描述系统的物理体系结构,包括组件图和部署图。

27 用例图(Use Case Diagram) 用例(Use Case)是从用户的观点对系统行为的一个描述。它从用户角度搜集系统需求,这样可靠而不易遗漏需求。 用UML用例图来描述洗衣过程如下图所示: 小人表示参与者(Actor),它代表拟建系统外部和系统进行交互的某类人或系统。椭圆代表用例。用例定义一组相关的由系统执行的动作序列。 Washing Machine User Wash Clothes

28 类图(Class Diagram) 一个类是一组具有类似属性和共同行为的事物。例如,属于洗衣机类的事物都有诸如品牌(brand name)、型号(model name)、序列号(serial number)和容量(capacity)等属性,它们的行为包括加衣物(add clothes)、加洗涤剂(add detergent)、取出衣物(remove clothes)等操作。

29 用UML表示要使用矩形方框,分为3个区域。最上面是类名,中间是属性,最下面是操作。类图是由这些类框和表明类之间如何关联的连线所组成。
说明:类的名称通常 首字母大写,属性和 操作通常首字母小写。 WashingMachine brandName modelName serialNumber capacity add-Clothes() add_Detergent() remove_Clothes()

30 对象图(Object Diagram) 对象是一个类的实例,是具有具体属性和行为的一个具体事物。如洗衣机品牌为海尔或小天鹅,一次最多洗涤重量为5公斤。 使用UML描述时和类图类似,但在对象名下要加下划线,对象名后加冒号加类名。 MyWasher:WashingMachine ……

31 顺序图(Sequence Diagram)
类图和对象图表达的是系统的静态结构,在一个运行的系统中,对象之间要发生交互,并且这些交互要经历一定的时间。UML顺序图所表达的正是这种基于时间的动态交互。

32 仍以洗衣机为例,洗衣机的构件包括一个注水的进水管(water pipe)、一个用来装衣物的洗涤缸(drum)和一个排水管(drain)。这些构件也是对象。
当“洗衣服”这个用例被执行时,假设已完成了“加衣物”、“加洗涤剂”和“开机”操作,那么应执行以下步骤: ⑴通过进水管向洗涤缸中注水; ⑵洗涤缸保持静止状态; ⑶水注满,停止注水;

33 ⑷洗涤缸往返旋转15分钟; ⑸通过排水管排掉洗涤后的脏水; ⑹重新开始注水; ⑺洗涤缸继续往返旋转洗涤; ⑻停止向洗衣机中注水; ⑼通过排水管排掉漂洗衣物的水; ⑽洗涤缸加快速度单方向旋转5分钟; ⑾洗涤缸停止旋转,洗衣过程结束。

34 Rotate unidirectionally
用一个顺序图说明进水管、洗涤缸和排水管之间随时间变化所经历的交互过程。 :Drum :Drain :Water Pipe Send fresh water Remain stationary Stop Rotate back and forth Send fresh water Send soapy water Rotate back and forth Stop Send rinse water Rotate unidirectionally Stop

35 对象符号下方垂直的虚线,称为对象生存线。沿对象生存线上展开的细长矩形称为激活,表示该对象正在执行某个操作,矩形的长度表示执行操作的持续时间。
带箭头的水平实线表示发送消息,消息可以发往其他对象或自身对象。图中对象之间发送的消息有6个,发往自身的消息有5个。

36 协作图(Collaboration Diagram)
系统的工作目标是由系统中各组成元素相互协作完成的,建模语言必须具备这种协作关系的表达方式。仍以洗衣机为例,在洗衣机构件的类集中又增加了一个内部计时器(Internal timer)。在经过一段时间后,内部计时器控制进水管停止注水,然后启动洗涤缸往返旋转。图中的序号代表命令消息的发送顺序,内部计时器先向进水管对象发送停止注水消息,后向洗涤缸对象发送往返旋转消息。

37 :Internal Timer 1: Stop 2: Rotate back and forth :Water Pipe :Drum

38 状态图(Statechart Diagram)
在任一给定的时刻,一个对象总是处于某一特定的状态。一个人可以是新生儿、婴儿、儿童、少年、青年、中年或老年。一个电梯可以处于上升、下降或停止状态。一台洗衣机可处于浸泡(Soak)、洗涤(Wash)、漂洗(Rinse)、脱水(Spin)或关机(Off)状态。用UML状态图表示如下,说明洗衣机可以从一个状态转移到另一个状态。

39 状态在图中表述为圆角矩形, 有两种比较特殊的状态:初始 状态(实心圆点)和结束状态 (实心圆点外加一个圆圈)。 只能有一个初始状态,可能有 多种结束状态。

40 活动图(Activity Diagram)
活动图类似于流程图,用于描述用例中的事件流结构。下图显示按顺序的UML活动图。 步骤4 步骤5 步骤6

41 组件图(Component Diagram)
组件图和部署图不以洗衣机为例,因为它们和整个计算机系统密切相关。组件是软件系统的一个物理单元,例如数据表、可执行文件、动态链接库、文档等。组件的UML表示为: 《DLL》 《HTML》 《EXE》 组件X 组件Y 组件Z

42 部署图(Deployment Diagram)
部署图显示了基于计算机系统的物理体系结构。它可以描述计算机和设备,展示它们之间的连接,以及驻留在每台机器中的软件。每台计算机用一个立方体来表示,立方体之间的连线表示这些计算机之间的通信关系。

43 《Processor》 PC Windows 2000 《Device》 monitor printer

44 Rose模型的四个视图 Use Case 视图 Logical 视图 Component 视图 Deployment 视图

45 Use Case 视图 Use Case视图包括系统中的所有角色、Use Case和Use Case框图,还可能包括一些Sequence或Collaboration框图。 Use Case视图是系统中与实现无关的视图。 Use Case视图关注系统功能的高层形状,而不关注系统的具体实现方法。

46 Logical 视图 Logical视图关注系统如何实现Use Case中提出的功能。它提供系统的详细图形,描述组件间如何关联。除此之外, Logical视图还包括需要的特定类、Class框图和Statechart框图。利用这些细节元素,开发人员可以构造系统的详细设计。

47 Component 视图 Component视图包含模型代码库、可执行文件、运行库和其他组件的信息。组件是代码的实际模块。 Component视图包含一个或多个组件图,描述组件之间的依赖关系。

48 Deployment 视图 Deployment视图关注系统的实际部署,显示网络上的进程和设备及其相互间的实际连接。一个系统只能有一个Deployment图。


Download ppt "Chapter 1 OBJECT-ORIENTED ANALYSIS AND DESIGN"

Similar presentations


Ads by Google