开发者

How to represent class instances in UML?

开发者 https://www.devze.com 2023-01-25 06:32 出处:网络
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 yo

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 |
                    |            ---------
                    |
            开发者_JS百科        |            ---------
                    +-----------| Child 3 |
                                 ---------

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


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


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


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".

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号