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:


2 Answers

0 votes
answered Dec 6, 2013 by plantuml (265,060 points)

Not sure about what you want to draw.

But it you want to have this, for example:

You can use that:

sprite $printer8 [15x15/8] {
object "<u>app-srv-37</u>\nSun Fire Printer <$printer8>" as Foo <<Device>> {
  name = "Dummy"
  id = 123


0 votes
answered Aug 13, 2014 by Fuhrmanator (1,580 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,580 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.