gpt4 book ai didi

uml - 带有 UML 类图的可选参数

转载 作者:行者123 更新时间:2023-12-05 00:58:09 26 4
gpt4 key购买 nike

是否有用于在 UML 类类型图中指定方法的可选参数的官方语法?

例如,我有一个方法:

public function abc( $arg = 0) { ... return void; }

我如何表明 $arg 是一个可选参数及其默认值?

最佳答案

UML 2.5 对参数列表有以下定义

  • <parameter-list> is a list of Parameters of the Operation in the following format: <parameter-list> ::= <parameter> [‘,’<parameter>]*
    <parameter> ::= [<direction>] <parameter-name> ‘:’ <type-expression>
    [‘[‘<multiplicity>’]’] [‘=’ <default>] [‘{‘ <parm-property> [‘,’
    <parm-property>]* ‘}’]

where:

  • <direction> ::= ‘in’ | ‘out’ | ‘inout’ (defaults to ‘in’ if omitted).
  • <parameter-name> is the name of the Parameter.
  • <type-expression> is an expression that specifies the type of the Parameter.
  • <multiplicity> is the multiplicity of the Parameter. (See MultiplicityElement – sub clause 7.5).
  • <default> is an expression that defines the value specification for the default value of the Parameter.
  • <parm-property> indicates additional property values that apply to the Parameter.


所以你可以使用
+ abc($arg : Integer = 0)
类型表达式不是可选的,所以你不能忽略它,但我想你可以想到一个约定,你可以使用像 Unspecified 这样的东西。

关于uml - 带有 UML 类图的可选参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33447030/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com