如何在UML类图中描述包含的映射? [英] How to describe a contained map in UML class diagram?

查看:137
本文介绍了如何在UML类图中描述包含的映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MyServer类,其中包含一个Map,其键是MyClientType对象,其值是MyClient对象。我想在类图中描述这种关系,但我想不出一种干净的方法。

I have a MyServer class that contains a Map whose keys are MyClientType objects and whose values are MyClient objects. I'd like to depict this relationship in a class diagram but I can't figure out a clean way to do that.

推荐答案

您可以使用合格的关联:

You can use a qualified association:

┌──────────┐             1 ┌───────┐
│ MyServer │Key│───────────│ Value │
└──────────┘               └───────┘

请参阅: http://etutorials.org/Programming/UML/Chapter+6.+Class+Diagrams+Advanced+Concepts/Qualified + Associations / (因为很难使用ASCII进行绘制)

还要注意,合格的关联会改变多重性:

Note also that a qualified association changes the multiplicity:

┌──────────┐          0..* ┌───────┐
│ MyServer │───────────────│ Value │
└──────────┘               └───────┘

┌──────────┐             1 ┌───────┐
│ MyServer │Key│───────────│ Value │
└──────────┘               └───────┘

上面显示的是从服务器到0-n的关联价值观。相比之下,合格的关联组织则表示,任何给定的键都只会与一个值相关联,并且您不能让键的值不存在。

The top illustrates an association from a server to 0-n values. By contrast, the qualified association says that any given key will be associated with only one value, and that you can't have a key an absent value.

这篇关于如何在UML类图中描述包含的映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆