阅读 UML 图 (POODR)
Reading UML diagrams (POODR)
我正在阅读 POODR 并试图理解 Sandi 的例子。
我特别想了解她的 UML 图是如何工作的。
例如第 75 页的图 4.8:
看着图片,我想到了一些问题:
moe Customer - 这表示 Customer
class 的一个实例,属性名称可能等于 moe
,或者它可能是存储在一个名为 moe
的变量,无论哪种方式,图表都使它看起来像这个框代表 "an object that is and instance of the Customer class"?
a TripFinder - 这有点令人困惑,因为它似乎也代表 "an object that is an instance of the TripFinder class"?
class Trip 和 class Bicycle - 现在我们看到 class
关键字,Sandi 也试图说这些框代表 "a Trip Class object" 或 "a Bicycle Class object"?两者都是"objects that are instances of the Class class"?
一个箭头似乎从 "sender" 指向 "message" 的 "receiver"。在转换为 "calling a method on the receiver object" 的代码中?箭头来自 moe 的事实意味着 Customer
class 中的某处有一个调用 TripFinder#suitable_trips
实例方法的方法。所以从 "sender" 到 "receiver" 的箭头告诉我们接收方的方法名称(又名方法签名?)而不是发送方的方法名称,对吗?
响应箭头是什么意思?它们只是 return 语句吗?虚线与实线的意义是什么?我知道在某些图表中它们代表依赖关系,但现在它们似乎代表发送消息和获取 return 语句。这和依赖是一回事吗?
为什么最后一行是实线?这只是一个错字吗?
我想,这是用绘画工具创建的,而不是 UML CASE 工具。
- (最多3个。)这个命名是错误的。生命线要么只用实例
name
、:classifier
描述,要么用 name:classifier
描述。见第570 17.3.4.1 规范中的生命线:
A Lifeline is shown using a symbol that consists of a rectangle forming its “head” followed by a vertical line (which may be dashed) that represents the lifetime of the participant. Information identifying the lifeline is displayed inside the rectangle in the following format:
<lifelineident> ::= ([<connectable-element-name>[‘[‘ <selector> ‘]’]] [: <connectable-element-type>] [<decomposition>]) | ‘self’`
<selector> ::= <expression>
<decomposition> ::= ‘ref’ <interactionident> [‘strict’]
- 正确
- 虚线 return 消息是可选的。为了清楚起见或显示特殊 return values/conditions,您可以放置它们。 UML 中的连接器符号最容易混淆。在所有(或大多数?)其他图中,带有空心箭头的虚线表示依赖关系。看。 p. 720 个规范 dash/arrow 正确使用(上例中的箭头不正确,因为 "artistic" 有曲线)。
- 是的。见1-3和置顶评论
可能,我会把那本书扔进垃圾堆...
我正在阅读 POODR 并试图理解 Sandi 的例子。
我特别想了解她的 UML 图是如何工作的。
例如第 75 页的图 4.8:
moe Customer - 这表示
Customer
class 的一个实例,属性名称可能等于moe
,或者它可能是存储在一个名为moe
的变量,无论哪种方式,图表都使它看起来像这个框代表 "an object that is and instance of the Customer class"?a TripFinder - 这有点令人困惑,因为它似乎也代表 "an object that is an instance of the TripFinder class"?
class Trip 和 class Bicycle - 现在我们看到
class
关键字,Sandi 也试图说这些框代表 "a Trip Class object" 或 "a Bicycle Class object"?两者都是"objects that are instances of the Class class"?一个箭头似乎从 "sender" 指向 "message" 的 "receiver"。在转换为 "calling a method on the receiver object" 的代码中?箭头来自 moe 的事实意味着
Customer
class 中的某处有一个调用TripFinder#suitable_trips
实例方法的方法。所以从 "sender" 到 "receiver" 的箭头告诉我们接收方的方法名称(又名方法签名?)而不是发送方的方法名称,对吗?响应箭头是什么意思?它们只是 return 语句吗?虚线与实线的意义是什么?我知道在某些图表中它们代表依赖关系,但现在它们似乎代表发送消息和获取 return 语句。这和依赖是一回事吗?
为什么最后一行是实线?这只是一个错字吗?
我想,这是用绘画工具创建的,而不是 UML CASE 工具。
- (最多3个。)这个命名是错误的。生命线要么只用实例
name
、:classifier
描述,要么用name:classifier
描述。见第570 17.3.4.1 规范中的生命线:
A Lifeline is shown using a symbol that consists of a rectangle forming its “head” followed by a vertical line (which may be dashed) that represents the lifetime of the participant. Information identifying the lifeline is displayed inside the rectangle in the following format:
<lifelineident> ::= ([<connectable-element-name>[‘[‘ <selector> ‘]’]] [: <connectable-element-type>] [<decomposition>]) | ‘self’` <selector> ::= <expression> <decomposition> ::= ‘ref’ <interactionident> [‘strict’]
- 正确
- 虚线 return 消息是可选的。为了清楚起见或显示特殊 return values/conditions,您可以放置它们。 UML 中的连接器符号最容易混淆。在所有(或大多数?)其他图中,带有空心箭头的虚线表示依赖关系。看。 p. 720 个规范 dash/arrow 正确使用(上例中的箭头不正确,因为 "artistic" 有曲线)。
- 是的。见1-3和置顶评论
可能,我会把那本书扔进垃圾堆...