Associative array in UML class diagram

2019-07-27 10:15发布

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

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

is this a correct way :

$config( key: 'localhost', value: '', key: 'username', value: '', key: 'password', value: '', key: 'dbname', value: '')

and underlined the whole line for static

1条回答
淡お忘
2楼-- · 2019-07-27 10:25

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.

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.

查看更多
登录 后发表回答