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

Slides:



Advertisements
Similar presentations
Which TV program is the video? 中国达人秀 China’s Got Talent 选秀节目 talent show talent n. 天资;天赋.
Advertisements

allow v. wrong adj. What’s wrong? midnight n. look through guess v. deal n. big deal work out 允许;准许 有毛病;错误的 哪儿不舒服? 午夜;子夜 快速查看;浏览 猜测;估计 协议;交易 重要的事.
期末考试作文讲解 % 的同学赞成住校 30% 的学生反对住校 1. 有利于培养我们良好的学 习和生活习惯; 1. 学生住校不利于了解外 界信息; 2 可与老师及同学充分交流有 利于共同进步。 2. 和家人交流少。 在寄宿制高中,大部分学生住校,但仍有一部分学生选 择走读。你校就就此开展了一次问卷调查,主题为.
考研英语复试 口语准备 考研英语口语复试. 考研英语复试 口语准备 服装 谦虚、微笑、自信 态度积极 乐观沉稳.
第七课:电脑和网络. 生词 上网 vs. 网上 我上网看天气预报。 今天早上看了网上的天气预报。 正式 zhèngshì (报告,会议,纪录) 他被这所学校正式录取 大桥已经落成,日内就可以正式通车 落伍 luòw ǔ 迟到 chídào 他怕迟到,六点就起床了.
胸痛中心的时间流程管理 上海胸科医院 方唯一.
-CHINESE TIME (中文时间): Free Response idea: 你周末做了什么?
Ch02物件導向程式設計 物件導向系統分析與設計.
专题八 书面表达.
Business English Reading
中职英语课程改革中 如何实践“以就业为导向,服务为宗旨”的办学理念
How can we become good leamers
Java Programming Hygiene - for DIDC
資料庫設計 Database Design.
Chapter’s major concepts
即兴中文讲演比赛 On-Site Speech 新型比赛项目
OMC 商業智庫 劉老師講題大綱 參考資料.
雅思大作文的结构 Presented by: 总统秘书王富贵.
How can we be a member of the Society? You should finish the following tasks if you want to be a member of the Birdwatching Society.
Understanding Interest Rates
Unit 5 Dialogues Detailed Study of Dialogues (对话) Exercises(练习)
Leftmost Longest Regular Expression Matching in Reconfigurable Logic
Could you please clean your room?
Homework 4 an innovative design process model TEAM 7
Unit 4 I used to be afraid of the dark.
Module 5 Shopping 第2课时.
關聯式資料庫.
形式语言与网络 计算环境构建 1.
Chapter 1 OBJECT-ORIENTED ANALYSIS AND DESIGN
Chapter 3 Case Studies.
第 1 章 ERP的演变.
單元3:軟體設計 3-2 順序圖(Sequence Diagrams)
Logistics 物流 昭安國際物流園區 總經理 曾玉勤.
肢體殘障人士 Physically handicapped
Retail Customer Online Registration 零售顧客線上註冊教學
Responsibility Accounting
创建型设计模式.
第9章 類別圖與物件圖 9-1 類別圖與物件圖的基礎 9-2 類別圖的符號 9-3 類別關係 9-4 物件圖 9-5 繪製類別圖與物件圖
This Is English 3 双向视频文稿.
第六章 : 資料模型之繪製 1. 前言 資料流程圖 ( DFD ) 及 處理邏輯工具
校園網路架構介紹與資源利用 主講人:趙志宏 圖書資訊館網路通訊組.
客户服务 询盘惯例.
Could you please clean your room?
基于任务的设计:思路、评价与实施 卫朝霞 西 安 交 通 大 学.
Chapter 5 Recursion.
Microsoft SQL Server 2008 報表服務_設計
IBM SWG Overall Introduction
Version Control System Based DSNs
Have you read Treasure Island yet?
第6章 資料庫設計與實體關聯模型 6-1 資料庫設計的基礎 6-2 實體關聯模型 6-3 建立實體關聯圖 6-4 實體關聯圖的常見錯誤
Guide to a successful PowerPoint design – simple is best
中国科学技术大学计算机系 陈香兰 2013Fall 第七讲 存储器管理 中国科学技术大学计算机系 陈香兰 2013Fall.
虚 拟 仪 器 virtual instrument
Common Qs Regarding Earnings
中央社新聞— <LTTC:台灣學生英語聽說提升 讀寫相對下降>
关联词 Writing.
Unit 5 First aid Warming up 《和你一样》 中国红十字会宣传曲 高二年级 缪娜.
從 ER 到 Logical Schema ──兼談Schema Integration
中考英语阅读理解 完成句子命题与备考 宝鸡市教育局教研室 任军利
徐迎晓 复旦大学软件学院 实现模型 徐迎晓 复旦大学软件学院.
Chapter 3 What Is Money?.
Unit 4 Body Language.
Chapter 10 Mobile IP TCP/IP Protocol Suite
MODELING GENERALIZATION & REFINING THE DOMAIN MODEL
英语单项解题思路.
怎樣把同一評估 給與在不同班級的學生 How to administer the Same assessment to students from Different classes and groups.
OOA/OOD UML RUP Architecture Pattern MDA
國際會計準則(IFRS)推動現況及因應之道
Example for CIC Report CIS-I.
Introduction to Computer Security and Cryptography
Presentation transcript:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

识别名词和名词短语 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)

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)

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

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)等

销售领域候选概念类 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的迭代中再考虑

POS系统领域模型

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.

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!

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.

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

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.

领域模型——添加关联

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

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

Flight leg---一段航程

新的关联 Table 9.2

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

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

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

Multiplicity

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

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

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

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

Multiple Associations Between Two Types

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

Unforgettable Relationships in the Store

Applying the Category of Associations Checklist

添加关联

解释见下一页

识别名词和名词短语 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)

领域模型——添加属性

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

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 收银条

解释见下页

Multiplicity From SalesLineItem to Item

1 to 1 分开打印每个商品

1 to * cup 3个 xx元

添加属性

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.

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 合伙人

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.

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

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 从这个角度看,不需要更新和维护模型,但并不是说更新模型就是错误 若想维护和更新模型,可重画白板上的图——要考虑谁将使用更新后的图、为什么使用? 如果没有实际的原因,就不用画

Sketching a Class Diagram Tool?

命名 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.

用关联 or 属性?

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

属性——某种数据类型,只关心值,不必要区分不同实体 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,

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

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.

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.

属性与外键

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

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)

数量与单位

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

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

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,

解决相似概念 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.

登记簿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好,

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

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

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

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

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

又一例(服务) 电信套餐 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.

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

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

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

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

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.

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

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的迭代中再考虑

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

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,

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]