Can I write comments in UML Class diagram?
Asked Answered
A

3

22

What symbol should I use ?

Ambi answered 23/10, 2010 at 8:14 Comment(0)
A
32

Below is an extract from the Unified Modeling Language specification. The complete specification is available at http://www.omg.org/spec/UML/2.3.

9.5.1 Comment

A comment is a textual annotation that can be attached to a set of elements.

Description

A comment gives the ability to attach various remarks to elements. A comment carries no semantic force, but may contain information that is useful to a modeler. A comment may be owned by any element.

Notation

A Comment is shown as a rectangle with the upper right corner bent (this is also known as a “note symbol”). The rectangle contains the body of the Comment. The connection to each annotated element is shown by a separate dashed line.

Presentation Options

The dashed line connecting the note to the annotated element(s) may be suppressed if it is clear from the context, or not important in this diagram.

alt text

Abide answered 23/10, 2010 at 9:6 Comment(2)
thank you. But I think if there is a symbol which stands for comments in UML, there will be more convenient. Just like "//" in java, then I can write a comment after declaring a property or method.Ambi
@Ambi Wang, perhaps what you want is a Object Constraint Language comment? From omg.org/spec/OCL/2.2 section 7.4.10: "Comments in OCL are written following two successive dashes (minus signs). Everything immediately following the two dashes up to and including the end of line is part of the comment. For example: -- this is a comment"Abide
I
6

If you would like to add comments to a UML source, depending on the renderer you can use -- or ' for a single line comment and /' '/ for a multi-line comment.

Example for PlantUML:

@startuml
' This is a single-line comment
Bob->Alice : hello
/' This is a multi-line comment. Use slash-and-single-quote
to split your comments to several
lines '/
@enduml
Infamy answered 8/12, 2020 at 20:21 Comment(1)
Thanks using the symbol ' helped me on plantuml, -- was not working for mePucka
A
3

Use --.

...if you are looking to comment the UML source, rather than render a comment in a diagram. As mentioned by WileCau above the reference for this is here: http://www.omg.org/spec/OCL/2.2 and is called an Object Constraint Language comment."

-- This section is about [etc.]
[My Thing] -> (Result)

This doesn't work in all UML renderers though - When I tried in PlantUML for example, it considered this a syntax error.

Ancilin answered 27/4, 2020 at 23:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.