UML类图中如何展示将库或单独的命名空间与类关联?

huangapple go评论51阅读模式
英文:

How is the UML notation in a Design Class Diagram demonstrated to associate a library or separate namespace with a class?

问题

假设我的以下设计类图:
UML类图中如何展示将库或单独的命名空间与类关联?

我想演示一些我的类,比如说 Program,使用了位于单独解决方案和命名空间中的 «package» Library 类,并通过项目依赖引用它。 这对程序的整体功能很重要。

我该如何做呢?«package» 表示法正确吗?

英文:

Suppose my following Design Class Diagram:
UML类图中如何展示将库或单独的命名空间与类关联?

I want to demonstrate some of my classes, let's say Program, utilizes the «package» Library class, which is located in a seperate solution and namespace and referenced through a project dependency. It is important for the overall functionality of the program.

How would I go about doing this? Is the «package» notation correct?

答案1

得分: 1

你想展示一个类使用另一个类吗?我猜你需要一个名为“usage”的元素。它用虚线箭头标记为“«use»”,从使用的类指向被使用的类。

附加说明:你定义了一个名为“«package»”的附加类型。虽然这是允许的,但这可能会引起混淆,因为有一个同名的模型元素。也许你想要展示一个名为“Library”的包。标记法是一个带有选项卡的矩形。包不能有操作。你需要定义一个由包拥有的类,该类定义了操作。或者,你可以定义“FunctionBehaviors”。它们可以由包拥有,是为非面向对象编程语言建模函数的正确方式。

英文:

You want to show that one class uses another? I guess a usage is the element you need. It is shown with a dashed arrow labeled «use», pointing from the using class to the used class.

Additional note: You defined a stereotype «package». While this is allowed, it might be confusing, since there is a model element of the same name. Maybe, you wanted to show a package called Library. The notation would be a rectangle with a tab. Packages can't have operations. You would need to define a class owned by the package that defines the operations. Alternatively, you could define FunctionBehaviors. They can be owned by a package and are the correct way to model functions for a non object oriented programming language.

huangapple
  • 本文由 发表于 2023年5月15日 06:06:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76249875.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定