创建UML图时应该编写构造函数吗? [英] When creating UML diagram should the constructors be written?
问题描述
我有一个作业要求我为实际的 Java 程序创建一个 UML 图.但是程序中有几个构造函数方法,我很困惑.我是否应该将这些构造函数方法添加到图表中?
I have a homework that requires me to create a UML diagram for an actual Java program. But there are several constructors methods in the program and I'm confused. Should I add these constructors methods to the diagram or not?
推荐答案
根据 UML 规范(2.5 版的第 11.4.4 节):
As per UML specification (section 11.4.4 of version 2.5):
构造函数是一个具有所属类类型的单个返回结果参数的操作,并标有标准构造型«Create».
A constructor is an Operation having a single return result parameter of the type of the owning Class, and marked with the standard stereotype «Create».
如果您要创建图表来记录代码,则应包括所有显式构造函数.
If you're creating a diagram to document a code you should include all explicit constructors.
如果您正在构建专注于功能构造函数的模型,则通常会省略.但是你的细节水平完全不同.
If you're building a model focusing on functionality constructors are typically omitted. But then your level of details is entirely different.
这篇关于创建UML图时应该编写构造函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!