您如何在UML类图中显示封装?

发布于 2025-01-22 16:41:16 字数 106 浏览 3 评论 0原文

我的问题非常简单。建模UML类图时,如何表示或显示封装?继承是使用箭头建模的,并通过在斜体中或以下箭头之间的类名称显示了一个抽象类,如所示,<<动物>>但是,您做什么封装呢?

My question is pretty straightforward. How do I represent or show encapsulation when modelling a UML class diagram? Inheritance is modelled using the arrows and an abstract class is shown by having the class name in italics or between the following arrows as shown, << Animals >> but what do you do for encapsulation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼眸印温柔 2025-01-29 16:41:16

班级的每个功能都可以具有可见性。私有功能使得封装实例状态成为可能。私有功能的符号是-在其名称前的登录(+公共范围, for Protected和〜<<< /代码>包装可见性)。

PS:没有“箭头”显示抽象类。取而代之的是,它在curly brockets中使用{Abstract}单词显示(或通过在斜体中写入名称来正确陈述)。

pps:“箭头”(&lt;&lt; ...&gt;&gt;)不是UML符号。您可能的意思是Guillemets:«...»。它们用于注释语言元素,这些元素没有独特的符号,例如datatypes。在这种情况下,关键字«datatype»显示上方。它们也可能是语言元素属性的符号。例如,具有issingleexecution = true的活动将显示关键字«单exection»。为什么不用卷曲括号表示这种情况,例如isabstract = true的神秘笼罩。最后,它们用于用户定义的语言元素(=刻板印象)。请注意,此类元素高于模型元素,即语言级别(也称为元级别)。因此,他们没有在建模系统级别上表达任何内容。刻板印象“动物”定义了一种新的语言元素,而不是动物。

Each feature of a class can have a visibility. Private features make it possible to encapsulate the state of the instance. The notation for a private feature is a - sign in front of its name (+ for public, # for protected and ~ for package visibility).

PS: An abstract class is not shown with "arrows". Instead it is shown with the word {abstract} in curly brackets (or as you correctly state by writing the name in italics).

PPS: "Arrows" (<<...>>) are not UML notation. You probably mean guillemets: «...». They are used to annotate language elements, that don't have a distinct notation, like DataTypes. In this case the keyword «dataType» is shown above the name. They could also be the notation for a property of a language element. For example an Activity with isSingleExecution=true will show the keyword «singleExecution». Why this case is not expressed with curly brackets, as in the case of isAbstract=true is shrouded in mystery. Finally they are used for user defined language elements (=stereotypes). Please note, that such elements are one level above the model elements, i.e. on the language level (also called meta level). Therefore, they don't express anything on the level of the modeled system. A stereotype «Animals» defines a new language element, but not an animal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文