如何在 UML 中将类标记为单例? [英] How do I mark a class as a singleton in UML?
本文介绍了如何在 UML 中将类标记为单例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 UML 图,我想在上面将一些类标记为单例(因为它们是).我怎么做?我是要发明一种新的刻板印象,还是只是添加评论,或者是否有一些现有的方法可以做到这一点?
解决方案
Craig Larman 的应用 UML 和模式"一书(第 3 版)给出了序列图的以下符号:
I have an UML diagram on which I want to mark some classes as singletons (because they are). How do I do that? Do I invent a new stereotype or do I just add a comment or are there some existing means to do that?
解决方案
Craig Larman's "Applying UML and Patterns" book (3rd edition) gives the following notation for a sequence diagram:
Note that it implies that before calling doA
the :Register
object manages to get access to the singleton via the standard way, e.g., getInstance()
. This makes the diagram more agile.
For a class diagram:
这篇关于如何在 UML 中将类标记为单例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文