How to represent class instances in UML?

雨燕双飞 提交于 2019-12-06 03:36:01

问题


I have a class diagram for my application which consists of several compositions and aggregations.

Now I want to have diagram based on the class diagram which shows class instances. A snapshot if you will. I need this because it would help discussing some functional requirements.

Class diagram:

 --------   1                 *  ------- 
| Parent |----------------------| Child |
 --------                        -------

"Instance" diagram:

 --------                        --------- 
| Parent |----------------------| Child 1 |
 --------           |            ---------
                    |
                    |            ---------
                    +-----------| Child 2 |
                    |            ---------
                    |
                    |            ---------
                    +-----------| Child 3 |
                                 ---------

Is there a diagram type for this? (Currently I'm mis-using a class diagram, where all my instances are separate classes)


回答1:


  • Use Object diagram or
  • Use keyword <<instance>> or
  • Underline class name



回答2:


An "instance" diagram in UML is called an Object Diagram.




回答3:


You can use the "Object Diagram" as Peter G. McDonald said.

See the wiki :Object Diagram Wiki
In UML if what you want doesn't exist you can adapt classic Diagram for what you want
something just like you did but with comment block to explain your choices
Documentation is as important as diagrams.

If you want to describe the life cycle of yours instances you can use "State machine diagram".



来源:https://stackoverflow.com/questions/4202970/how-to-represent-class-instances-in-uml

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