简体   繁体   English

如何使用具有主要方法且没有字段的类制作 UML 图

[英]How to make a UML diagram with a class that has a main method and no fields

I have a class that has a main() method and no fields and also it doesn't have a constructor.我有一个类,它有一个main()方法,没有字段,也没有构造函数。 This class is just a simple class in a larger project, that I did it all by myself and that is why I feel like something is wrong.这个类只是一个大项目中的一个简单的类,我自己做了这一切,这就是为什么我觉得有些不对劲。

I have to document the project with an UML diagram.我必须用 UML 图记录项目。 I don't know what am I supposed to write in the diagram for such a simple class.对于这样一个简单的类,我不知道我应该在图表中写什么。 Just the static methods?只是静态方法?

How do I write the main class in the UML?如何在 UML 中编写主类?

What you describe is a situation that is common in class-only languages, such as Java or C# , where every code must be to encapsulated in a class.您所描述的情况在纯类语言中很常见, 例如 JavaC# ,其中每个代码都必须封装在一个类中。

In this case, the main() method is a static method that is called to start your application.在这种情况下, main()方法是一个静态方法,调用它来启动您的应用程序。 Usually it is a technical requirement and not very important feature for the OO design.通常它是一个技术要求,对于 OO 设计来说不是很重要的特性。 This is why it rarely appears in a class diagram.这就是为什么它很少出现在类图中的原因。

But it is a static method like any other, and in UML you could just want to show it as a static operation , by underlining its name.但它和其他任何方法一样都是静态方法,在 UML 中,您可能只想通过在其名称下划线来将其显示为静态操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM