Presentation is loading. Please wait.

Presentation is loading. Please wait.

徐迎晓 xuyingxiao@126.com 复旦大学软件学院 领域模型——概念的可视化 徐迎晓 xuyingxiao@126.com 复旦大学软件学院.

Similar presentations


Presentation on theme: "徐迎晓 xuyingxiao@126.com 复旦大学软件学院 领域模型——概念的可视化 徐迎晓 xuyingxiao@126.com 复旦大学软件学院."— Presentation transcript:

1 徐迎晓 xuyingxiao@126.com 复旦大学软件学院
领域模型——概念的可视化 徐迎晓 复旦大学软件学院

2 outline 不同视角的模型 什么是领域模型 概念类 识别和提取概念类 创建领域模型步骤 几个问题 Process 命名 概念类or属性?
属性与外键 数量和单位 添加Specification/ description 相似概念问题 Modeling the Unreal World 不同视角的模型 Process

3

4

5

6 什么是领域模型 概念类 识别和提取概念类 创建领域模型步骤 几个问题 不同视角的模型 Process 命名 概念类or属性? 属性与外键
数量和单位 添加Specification/ description 相似概念问题 Modeling the Unreal World 不同视角的模型 Process

7 Use cases: Domain model
important requirements analysis artifact, but are not object-oriented. emphasize a process view of the domain. Domain model The most important artifact to create in OOA

8 领域模型domain model是概念类或 问题领域中实际对象的可视化表达,又称为:
概念模型conceptual models 领域对象模型domain object models 分析对象模型analysis object models.

9 什么是领域模型 概念类 识别和提取概念类 创建领域模型步骤 几个问题 不同视角的模型 Process 命名 概念类or属性? 属性与外键
数量和单位 添加Specification/ description 相似概念问题 Modeling the Unreal World 不同视角的模型 Process

10 概念模型 领域模型显示问题领域中对建模者有意义的概念类 领域模型表达的是现实世界中的概念类,而不是软件构件(不是软件类或带有职责的软件对象)
OOA中创建的最重要的制品 识别大量对象或概念类—heart of OOA 领域模型表达的是现实世界中的概念类,而不是软件构件(不是软件类或带有职责的软件对象) 识别概念类是问题域调查的一部分 UML中的类图可以显示领域模型

11 使用UML表示法,领域模型用一组不带操作的类图来表示,可显示:
领域对象或概念类 概念类之间的关联 概念类的属性

12 可视化字典 领域模型将领域中的单词、概念类可视化,并将其相互关联(比文字更容易阅读)
领域模型显示了视图或抽象的一部分,而将建模者不感兴趣的细节忽略。 创建领域模型同时有助于澄清领域中术语和词汇——可视化字典

13

14

15

16

17

18

19 不是软件设计 领域模型是现实世界问题领域中事物的可视化,而不是软件构件的可视化 不是软件制品——如window, database
不带有职责和方法

20 领域模型——显示现实世界的概念

21 领域模型——避免软件制品或类

22

23 什么是领域模型 概念类 识别和提取概念类 创建领域模型步骤 几个问题 不同视角的模型 Process 命名 概念类or属性? 属性与外键
数量和单位 添加Specification/ description 相似概念问题 Modeling the Unreal World 不同视角的模型 Process

24 创建领域模型步骤 列出候选概念类 在领域模型中画出候选概念类 添加关系 添加属性

25 什么是领域模型 概念类 识别和提取概念类 创建领域模型步骤 几个问题 不同视角的模型 Process 命名 概念类or属性? 属性与外键
数量和单位 添加Specification/ description 相似概念问题 Modeling the Unreal World 不同视角的模型 Process

26 领域模型——识别和提取概念类 用概念类种类列表 识别名词短语 使用分析模式

27

28 使用概念种类列表 store and airline reservation domains. 饥饿,恐高症
Tangible切实的,有形的,真实的 饥饿,恐高症

29

30 识别名词和名词短语 it is another source of inspiration. Care:
a mechanical noun-to-class mapping isn't possible words in natural languages are ambiguous it is recommended in combination with the Conceptual Class Category List technique. Some are candidate conceptual classes Some maybe ignored in this iteration ("Accounting" and "commissions") Some may be attributes of conceptual classes.(Price)

31

32 it is another source of inspiration. Care:
a mechanical noun-to-class mapping isn't possible words in natural languages are ambiguous it is recommended in combination with the Conceptual Class Category List technique.

33 Some are candidate conceptual classes
Some maybe ignored in this iteration ("Accounting" and "commissions") Some may be attributes of conceptual classes.(Price)

34 使用分析模式 由专家创建并公开的部分领域模型 Martin Fowler 分析模式:可复用的对象模型
Analysis Patterns Reusable Object Models Addison Wesley/Pearson 机械工业出版社 中国电力出版社(影印版)

35 Martin Fowler的主要精品著作有
《重构-改善既有代码的设计》(Refactoring: Improving the Design of Existing Code)、 《UML精粹:标准对象建模语言简明指南》(UML Distilled:A Brief Guide to the Standard Object Modeling) 《分析模式:可重用的对象模型》(Analysis Patterns:Reusable Object Models) 《规划极限编程》(Planning Extreme Programming) 《企业应用架构模式》(Patterns of Enterprise Application Architecture)等

36

37 销售领域候选概念类 Report Objects—Include Receipt in the Model?
No--In general, showing a report of other information in a domain model is not useful since all its information is derived from other sources; Yes--A receipt has a special role in terms of the business rules.赋予持有者退货的权利(return bought items) 本次迭代未考虑退货,因而不包括Receipt,处理Handle Returns的迭代中再考虑

38 POS系统领域模型

39 Group size You should preferably be 5-7 persons in the group that identifies concepts. With a group of this size you get several perspectives and ways of thinking. And if the group is larger it can be difficult to agree on the concepts. The group should contain a mixture of persons, e. g. analysts, designers, programmers. There should be at least one domain expert in the group One person is the leader. His/her job is the make the group work dynamically. One should have clear objectives for each meeting! Disputes should be solved harmonically, so it is important that the leader is trusted by everyone.

40 A process for identifying concepts
1. each person is assigned to search for concepts in different places. 2. the whole group meets and finds concept candidates using brainstorming. All possible concepts should be includes! All concepts are equally important!

41 3. When no more concepts are found, you have a good starting point for identifying the suitable concepts for the problem area. Divide the concepts into three groups: 1. Concepts which everybody thinks are important 2. Concepts that fall outside the problem area, are more suitable as attributes, concepts with the same meaning etc. 3. Concepts which fall in between these groups. 4. Discuss the concepts in group 3 which not everyone agrees on. These concepts should be treated consistently.

42 Principles for brainstorming
All ideas are equally important Think quickly, not too much consideration; think more later Let everyone speak (Round-Robin Technique) A good mood can be an important strength

43 Good concepts It is important to point out that you probably haven’t found all appropriate concepts after looking for them the first time, if the problem area isn’t very trivial! The more you work with the domain model,the better it gets. It can take several iterations to reach a stable model.

44 领域模型——添加关联

45 在美国有孩子的家庭中,太太经常嘱 咐他们的丈夫下班以后要为孩子买尿布

46 添加关联 从常用关联列表中导出的关联-由此开始 玮平 漫画

47 Flight leg---一段航程

48

49 新的关联 Table 9.2

50

51 高优先级关联 • A is a physical or logical part of B.
• A is physically or logically contained in/on B. • A is recorded in B.

52 关联指南 集中于需要保存一定时间的关系(Need to know关联) 提取概念类比识别关联更重要,主要时间应放在识别概念类
太多的关联会使领域模型更混乱 耗时,而效果递减 避免显示冗余或可导出的关联

53 角色 Each end of an association is called a role.
Roles may optionally have: name ftp multiplicity expression Navigability(导航) Interface specifier 接口说明(接口限定符)

54 Multiplicity

55

56 The multiplicity value communicates(表明) how many instances can be validly associated with another, at a particular moment, rather than over a span of time. 一夫一妻制 旧车任一时刻只能被一个经销商进货,但一段时间内可能反复被进货 任一时刻只能与一人结婚,但一段时间内可能与多人结婚

57 The multiplicity value is dependent on our interest as a modeler and software developer
现实中,Item可以不存储在任何Store中(如已卖出),但软件中,Item总与一个Store相联系

58 Naming Associations TypeName-VerbPhrase-TypeName format
verb phrase creates a sequence that is readable and meaningful in the model context. start with a capital letter association represents a classifier of links between instances; in the UML 两种常用格式 Paid-by PaidBy

59 default direction to read an association name is left to right or top to bottom
not a UML default, but a common convention.

60

61 Multiple Associations Between Two Types

62 Domain Modeling期间,association只是对现实世界的分析,不意味着需要实现
实现关联最常用的方法:使用属性

63 Unforgettable Relationships in the Store

64 Applying the Category of Associations Checklist

65

66

67 添加关联

68 解释见下一页

69 识别名词和名词短语 it is another source of inspiration. Care:
a mechanical noun-to-class mapping isn't possible words in natural languages are ambiguous it is recommended in combination with the Conceptual Class Category List technique. Some are candidate conceptual classes Some maybe ignored in this iteration ("Accounting" and "commissions") Some may be attributes of conceptual classes.(Price)

70

71 领域模型——添加属性

72

73 属性 领域模型中应该包含哪些属性?

74 Attribute of Sale a receipt (which reports the information of a sale) normally includes a date and time, and management wants to know the dates and times of sales for a variety of reasons. Consequently, the Sale conceptual class needs a date and time attribute. 举例:sale中应该包含哪些属性? 收银条包含日期信息,经理要知道每笔销售的日期 Receipt 收银条

75 解释见下页

76 Multiplicity From SalesLineItem to Item

77 1 to 1 分开打印每个商品

78 1 to * cup 3个 xx元

79 添加属性

80 Exercise Make a class diagram that captures the following:
A company consists of departments and employees. A department has responsibility for zero, one or more projects. A company has: name, address and telephone. A department has name. A project has name. An employee has name, address, a social security number (SSN) and is participating in zero, one or more projects. Let the class diagram show: classes with attributes, relations (with role names) between the classes and multiplicity for the relations.

81

82 A bank has customers with different status
A bank has customers with different status. The bank offers different services depending on the status of a customer. A customer can have several accounts and several loans. For each customer the system must know his/her income for the last 12 months. Each customer has a collection of other customers which serve as his/her associates. An associate can be warrantor ( 担保人) for a loan and can also upgrade the status of a customer. Each loan in the bank is associated with the house that it is used for. A house loan may need a warrantor. A customer may also use another house already in his/her possession as a security抵押品 for a loan. In that case, information about the address, taxvalue etc. for the security house is needed. The customer must also always specify the same information for the house which the loan concerns. Only customers of the bank may have a loan. Customers with payment complaints during the last three years cannot get loans. taxvalue税额 Associate 合伙人

83 A bank has customers with different status
A bank has customers with different status. The bank offers different services depending on the status of a customer. A customer can have several accounts and several loans. For each customer the system must know his/her income for the last 12 months. Each customer has a collection of other customers which serve as his/her associates. An associate can be warrantor ( 担保人) for a loan and can also upgrade the status of a customer. Each loan in the bank is associated with the house that it is used for. A house loan may need a warrantor. A customer may also use another house already in his/her possession as a security抵押品 for a loan. In that case, information about the address, taxvalue etc. for the security house is needed. The customer must also always specify the same information for the house which the loan concerns. Only customers of the bank may have a loan. Customers with payment complaints during the last three years cannot get loans.

84

85

86

87

88

89 什么是领域模型 概念类 识别和提取概念类 创建领域模型步骤 几个问题 不同视角的模型 Process 命名 概念类or属性? 属性与外键
数量和单位 添加Specification/ description 相似概念问题 Modeling the Unreal World 不同视角的模型 Process

90 agile modeling approach,
the purpose of creating a domain model is to quickly understand and communicate a rough approximation of the key concepts. agile models are usually discarded shortly after creation 从这个角度看,不需要更新和维护模型,但并不是说更新模型就是错误 若想维护和更新模型,可重画白板上的图——要考虑谁将使用更新后的图、为什么使用? 如果没有实际的原因,就不用画

91 Sketching a Class Diagram
Tool?

92 命名 mapmaker strategy also named the Use the Domain Vocabulary strategy
Make a domain model in the spirit of how a cartographer or mapmaker works: Use the existing names in the territory(地区,领域). Exclude irrelevant features(地形图,人口分布) Do not add things that are not there.

93 用关联 or 属性?

94 属性——简单数据类型 关联——复杂数据类型

95 属性——某种数据类型,只关心值,不必要区分不同实体
Primitive data type number, string, boolean, date, or time non-primitive data type(also known as value objects, a non-primitive class, Data Type Classes) 概念类——需要区分不同实体 PhoneNumber? 考虑不同组成部分时作为non-primitive data type 概念类——需要区分不同实体 it is meaningful to distinguish (by identity) between two separate instances of a Person whose names are both "Jill Smith" compare the memory addresses of Person instances,

96 概念类or属性 常见错误: 将应该作为概念类的当做属性 ----规则:若在现实世界中我们不把X当作数字或文本,则X可能是概念类而不是属性
Store是一个组织,不是数字、文本,应该作为概念类

97 In the real world, a destination airport is not considered a number or text—it is a massive thing that occupies space. Therefore, Airport should be a concept.

98 If in doubt, make it a separate concept
If in doubt, make it a separate concept. Attributes should be fairly rare in a domain model.

99 属性与外键

100 undesirable because its purpose is to relate the Cashier to a Register object.

101 Better relate types with an association, not with an attribute.
There are many ways to relate objects—foreign keys being one defer how to implement the relation until design to avoid design creep(creep, not anticipated near the start)

102 数量与单位

103 Most numeric quantities should not be represented as plain numbers.
price or velocity 速度 These are quantities with associated units,

104 Solution( In the general case,)
represent Quantity as a distinct conceptual class, with an associated Unit 把Quantity当作conceptual class, with an associated Unit

105 Quantities are considered data types (unique identity of instances is not important)
it is acceptable to collapse their illustration into the attribute section of the class box 把Quantity当作data types,

106 解决相似概念 A thing that records sales and payments, Register登记簿:
a book that logged sales and payments. cash register:收银机 Acquire a generalized meaning over time. POST: point-of-sale terminal. In computerese, a terminal is any end-point device in a system, such as a client PC, a wireless networked PDA, and so forth.

107 登记簿Register和POST功能一样。
——各有优缺点 as a rule of thumb, a domain model is not absolutely correct or wrong, but more or less useful; it is a tool of communication. mapmaker principle, “POST” is a term familiar in the territory——POST好,易于交流 从模型的目的:抽象,实现独立——Register好,

108 Modeling the Unreal World
some candidate conceptual classes related to a telecom-munication switch: Message, Connection, Port, Dialog, Route, Protocol.

109 添加Specification/ description
the need for specification conceptual classes is common in many domain models.

110 itemID 所有杯子都用相同的itemID
serial number 各个杯子具有唯一的序列号

111 规则:使用Specification/ description的场合
当需要对Item或服务进行描述(独立于这些条目或服务当前存在的任何具体例子)时 删除实例会导致有用信息丢失时(这些信息和被删除的东西不恰当地关联在一起了) 要减少信息冗余

112 common in sales , product, and manufacturing Domains
a ProductSpecification (or ItemSpecification, ProductDescription ...) conceptual class records information about items does not represent an Item, it represents a description of information about items it is common to state that an XSpecification Describes an X

113 又一例(服务) 电信套餐 PackageDescription rates per minute
wireless Internet content cost 实际卖出去的套餐 gold package sold to XXX on Jan. 1, 2047 at $55 per month As another example, a mobile phone company sells packages such as "bronze," "gold," and so forth. It is necessary to have the concept of a description of the package (a kind of service plan describing rates per minute, wireless Internet content, the cost, and so forth) separate from the concept of an actual sold package (such as "gold package sold to Craig Larman on Jan. 1, 2047 at $55 per month"). Marketing needs to define and record this service plan or MobileCommunicationsPackageDescription before any are sold.

114 同一种图可用于不同视角的模型 Essential or conceptual perspective
现实世界 Specification perspective 独立于语言的软件世界 Implementation perspective 具体语言实现

115

116 解决语义鸿沟-用相同的名称 representational gap or semantic gap

117 Class general term representing either a real-world thing (a conceptual class) or software thing (a software class).

118 Conceptual class real-world concept or thing
A conceptual or essential perspective The UP Domain Model contains conceptual classes.

119 Software class Design class
a class representing a specification or implementation perspective of a software component, regardless of the process or method. Design class a member of the UP Design Model a synonym for software class either a specification or implementation perspective, as desired by the modeler.

120 Implementation class a class implemented in an object-oriented language such as Java.

121 Report Objects—Include Receipt in the Model?
No--In general, showing a report of other information in a domain model is not useful since all its information is derived from other sources; Yes--A receipt has a special role in terms of the business rules.赋予持有者退货的权利(return bought items) 本次迭代未考虑退货,因而不包括Receipt,处理Handle Returns的迭代中再考虑

122 领域模型和UP 初始-no 细化- 主要在此创建,当需要理解值得注意的概念,并映射到部分设计工作的类中
熟练者每次迭代只需几小时来开发领域模型,若是用预定义的分析模式,还将更快

123 The UP Business Object Model vs. Domain Model
[The UP BOM] serves as an abstraction of how business workers and business entities need to be related and how they need to collaborate in order to perform the business. [RUP] 用几种不同的图表示 (class, activity, and sequence) 显示整个企业如何运作 若做整个企业的business process engineering最有用 业务建模Business Modeling还可以有业务对象模型Business Object Model Domian Model是其一个实例 [The UP BOM] business workers and business entities如何相互关联和协作以完成相应的业务 need to be related and how they need to collaborate in order to perform the business. [RUP] ========= [The UP BOM] serves as an abstraction of how business workers and business entities need to be related and how they need to collaborate in order to perform the business. [RUP] represented with several different diagrams (class, activity, and sequence) illustrate how the entire enterprise runs most useful if doing enterprise-wide business process engineering,

124 Domain Model BOM的一个子集,更常创建
You can choose to develop an "incomplete" business object model, focusing on explaining "things" and products important to a domain. ... This is often referred to as a domain model. [RUP] =====E====== more commonly created subset artifact or specialization of the BOM. You can choose to develop an "incomplete" business object model, focusing on explaining "things" and products important to a domain. ... This is often referred to as a domain model. [RUP]


Download ppt "徐迎晓 xuyingxiao@126.com 复旦大学软件学院 领域模型——概念的可视化 徐迎晓 xuyingxiao@126.com 复旦大学软件学院."

Similar presentations


Ads by Google