Associative array in UML class diagram

六月ゝ 毕业季﹏ 提交于 2019-12-11 07:54:11

问题


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:


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.



来源:https://stackoverflow.com/questions/18558319/associative-array-in-uml-class-diagram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!