UML类图中的关联数组

问题描述:

我有一个要在类图中显示的数组.

I have an array that I want to show in a class diagram.

protected static $config = array(
        'host' => 'localhost',
        'username' => '',
        'password' => '',
        'dbname' => ''
    ); 

这是正确的方法吗?

并在整行上加上下划线表示为静态

and underlined the whole line for static

通常不会使用UML进行配置,但是您可以这样做.您需要创建实例规格以获得所需的结果.

Usually one doesn't use UML to configure things, but you can do it. You would need to create instance specifications to get the result you want.

您可以创建一个实例规范,类型为 AssociativeArray associativeArrayInstanceSpec1 ,该规范由许多其他的 AssociativeArrayEntry 实例规范组成,每个实例规范都有一个特定的键和价值.然后,您可以在 SomeClass 中将具有默认值的属性声明为 config:AssociativeArray [1] = associativeArrayInstanceSpec1 .

You could create an instance specification, associativeArrayInstanceSpec1 of type AssociativeArray that composes a bunch of other AssociativeArrayEntry instance specifications that each have a specific key and value. Then you could declare a property with a default value in SomeClass as config : AssociativeArray [1] = associativeArrayInstanceSpec1.