Attach note to specific method/attribut of a class

0 votes
asked May 31, 2015 in Wanted features by Fuhrmanator (1,580 points)

In class diagrams, I'd like for a note to be attached to a specific element of a class, e.g., an attribute or a method.

I was thinking this could be done if ,around an attribute or method, there was an invisible node in GraphVis. This could be specified with the "as" keyword. It's an idea, but I don't know if it would work.

Here's a suggestion for the syntax:

class A {
  member1 as m1
  methodB() as mb
}
note right of m1
  This member is annotated
end note
note right of mb
  This method is now explained in a UML note
end note

2 Answers

+2 votes
answered Jun 3, 2015 by plantuml (255,000 points)
selected Apr 24, 2017 by Fuhrmanator
 
Best answer

Right now, we stick on :: mainly because the implementation is simpler.

You can try with the last beta: https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

@startuml
class A {
  member1
  memberB()
  member2
}
note right of A::member1
  This member is annotated
end note
note right of A::memberB
  This method is now explained in a UML note
end note
note left of A::member2
  Yet **another**
  note on several lines.
end note
@enduml


We are pretty sure that in some case, this won't work very well. Especially if other links are added between class A and other classes.
So any feedback is welcome.

PS:
About specific link like:
a1::b -> b1 'specific link
This is really another story than having notes on method/attribut.
It's much complex to implement, so we'd better to focus first on just notes, before (eventually) moving forward.
 

+1 vote
answered May 31, 2015 by plantuml (255,000 points)

Hi,

Good idea. We have started to work on a slightly different solution.

With version 8025, you can have:

@startuml
class A {
  member1
  memberB()
}
note right of A::member1
  This member is annotated
end note
note right of A::memberB
  This method is now explained in a UML note
end note
@enduml

The implementation is not finished yet, but basically, we group all notes on members in the same node (from a Graphviz point of view).

Then when drawing, we draws separate notes (with a top-down direction). Links between those notes and the members are still to be coded (as you can see).

commented Jun 1, 2015 by Fuhrmanator (1,580 points)
Another use for this is in object diagrams:
object ":A" as a1 {
  b
}
object ":B" as b1 {
}
a1 -> b1 ' general link
a1::b -> b1 'specific link

It could be useful to show specifics of a link (even if it's not official UML).

When I thought of "as" keyword in defining the connection point, I considered it might simplify re-use of the identifier in other linkings. With Class::member syntax, it has to be identified everywhere. Maybe this is not a big difference.
...