How to note a class of object in object diagram?

0 votes
asked Dec 6, 2013 in To be sorted by anonymous

How can I add information about the class of the object in object diagram ?

Can I use instance specifications like the ones described here: http://www.uml-diagrams.org/uml-core.html#instance-specification-core

?

2 Answers

0 votes
answered Dec 6, 2013 by plantuml (295,000 points)

Not sure about what you want to draw.

But it you want to have this, for example:

You can use that:

@startuml
sprite $printer8 [15x15/8] {
00098888A110000
000I000088GI000
235I0GOOOW0I532
R00I0GOOOW0I00R
R11HHHHHHHHH11R
S9999999999999S
YaZZZZZZZZZZZaY
0GWWWWWWWWWWWG0
}
object "<u>app-srv-37</u>\nSun Fire Printer <$printer8>" as Foo <<Device>> {
  name = "Dummy"
  id = 123
}
@enduml

See http://www.plantuml.com/plantuml/form?url=JO-v2i9048RxUOeXs8ep2S4LrWL1ZAaYII5UnHgtY9237AA8x-u6pw_vZsdcRwewQmqEh1IjgGNksB-oFn87l0CHJOHbncmjzJdiZH11h-1wVaX154Lh2dtFXRY_lpDH337pyWDp3CdadmGsUlj3Ru22zO-0u07byMpI5XtPALrLmwQ-3Bsn77LgNoHTWOkiDhXwlOxoEq8vg1jSb2LAEJUNB3LAsJc8XSuDJj6PTtb-Sz0ssSbcTZruF040

0 votes
answered Aug 13, 2014 by Fuhrmanator (1,700 points)

Just use the " : " in the name of the object, and <u> to underline (but I think that's not necessary in UML2). Here's an example:

Object diagram with instance specification

left to right direction
object "newPatient:Patient" as p2 {
id : String = "38-545-137"
name = John Doe
gender: Gender = male
}
object "checkAcct:Account" as checkAcct <<interface>>
object "<u>newPatient:</u>" as p
note right 
 Underlining of instances
 is old (UML 1.0)?
end note
object ":Customer" as c

 
commented Oct 29, 2015 by alberto (140 points)
edited Oct 29, 2015 by alberto
"I think that's not necessary in UML2"

What makes you think so? According to the OMG Unified Modeling Language Version 2.5:
"9.8.4 Notation
An InstanceSpecification is depicted using similar notation to its classifiers , but in place of the Classifier name appears an underlined concatenation of the instance name (if any), a colon (‘:’) and the Classifier name or names. [...]"

The underlining looks mandatory to me...
commented Oct 29, 2015 by Fuhrmanator (1,700 points)
Indeed. I'm now looking at the OMG standard, and I see Figures 11.6 and 11.7 which (to me) illustrate why underlining is important in object diagrams (I was thinking it didn't matter since underlining was removed from participants).

It denotes a concrete object, as opposed to a named instance - it's a subtle but important difference.
...