UML:包括静态函数

发布于 2024-11-19 06:54:33 字数 169 浏览 1 评论 0原文

UML 中是否有一种标准方法来对与对象交互的多个静态方法(不是类的一部分)进行建模?我正在开发一个使用 JNI(Java 本机接口)来支持 Android 上的 C++ 代码的项目。

我本来打算简单地将函数集合视为另一个类,但感觉必须有更好的方法。我应该完全忽略 JNI 并只包含它们代表的 Java 类吗?

Is there a standard way in UML to model several static methods (not part of a class) that interact with objects? I'm working on a project that uses the JNI (Java Native Interface) to support C++ code on Android.

I was planning on simply treating the collection of functions as another class, but feel like there has to be a better approach. Should I ignore the JNI entirely and just include the Java class they represent?

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

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

发布评论

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

评论(3

满地尘埃落定 2024-11-26 06:54:33

在某些情况下,模块或命名空间可以被视为“对象”。

您可以将带有非对象函数的库“封装”为“对象”,并添加构造型。

+-----------------------------------------------------------+
|..........................<<library>>......................|
|.............................Strings.......................|
+-----------------------------------------------------------+
|..+...String:..Date2Str(Date Value)........................|
|..+...String:..Mid(String Source, int Index, int Count)....|
|..+...String:..Reverse(String Source)......................|
+-----------------------------------------------------------+

干杯。

In some circumstances, a module, or, namespace can be considered an "object".

You could "encapsulate" your library with non object functions as an "object", and addan stereotype.

+-----------------------------------------------------------+
|..........................<<library>>......................|
|.............................Strings.......................|
+-----------------------------------------------------------+
|..+...String:..Date2Str(Date Value)........................|
|..+...String:..Mid(String Source, int Index, int Count)....|
|..+...String:..Reverse(String Source)......................|
+-----------------------------------------------------------+

Cheers.

饮惑 2024-11-26 06:54:33

从根本上来说,UML 采用了 OO 范式。所以它不提供第一类功能。因此,对函数建模的唯一方法是使用方法(基于类或基于实例)。

唯一的其他选择是具体化函数,即为每个函数创建一个类。但我不确定这真的是你所追求的。

我本来打算简单地治疗
函数的集合作为另一个函数

这可能就是我的建议。

我应该完全忽略 JNI 吗?
只需包含 Java 类即可
代表?

取决于您想要在模型中显示的内容。对于观众来说,了解通过 JNI 调用的函数重要吗?或者相反,目的更多的是“领域模型”(即显示概念实体以及它们如何关联并抽象实现语言选择)?

嗯。

Fundamentally, UML adopts an OO paradigm. So it doesn't provide for 1st class functions. Therefore the only way to model functions is to use methods (either class- or instance based).

The only other option is to reify the functions, i.e. cleate a class for each. However I'm not sure that's really what you're after.

I was planning on simply treating the
collection of functions as another
class

That's probably what I'd have suggested.

Should I ignore the JNI entirely and
just include the Java class they
represent?

Depends on what you're trying to show in the model. Is it important for the audience to understand the functions are called through JNI? Or conversely, is the purpose more of a "domain model" (i.e. showing the conceptual entities and how they relate and abstracting implementation language choices)?

hth.

柒七 2024-11-26 06:54:33

UML 是一种面向对象系统的建模语言。因此它没有任何独立静态函数的构造。

您可以为静态方法创建一个 Facade 类并显示该 Facade 和 Java 类的交互。

但无论如何首先你应该问:

通过在我的 UML 图上显示这些内容我会得到什么好处?

如果 UML 不能帮助您“为了您的利益”,请使用其他工具。即使您的目标是向其他人展示您的内部结构,也可以选择一个编辑器以编程方式显示您的基础设施,将其录制为视频,然后将其提供给观众。

UML is a modeling language for Object Oriented Systems. So it does not have any construct for standalone static functions.

You may Create a Facade class for your static methods and show the interaction of that Facade and Java classes .

But anyway first you should ask:

What kind of benefit will i get by showing those on my UML diagrams?

If UML does not help you "for your benefit", use other tools. Even if your aim is to show your internal structure to others, pick up an editor show programatically your infrastructure, record that as video then serve it to audience.

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