1

I am making a structural diagram in UML using classes and objects and wondered if I was doing it correctly.

Would the following (on the right) be the correct way to represent an object diagram of the left-hand side class diagram?

enter image description here

TylerH
  • 20,799
  • 66
  • 75
  • 101
DonnellyOverflow
  • 3,981
  • 6
  • 27
  • 39

1 Answers1

4

No. You are using a Generalization which is not the case. Either leave that out or use a stereotyped dependency <<instanceOf>>. Note that this is no standard as per UML specs. But those specs leave you the freedom to express is this way.

The class from which the object is instantiated is already shown in the name objectName::className.

From Annex A p. 683 of the UML 2.5 specs, which describes the organization of diagram types:

NOTE. This taxonomy provides a logical organization for the various major kinds of diagrams. However, it does not preclude mixing different kinds of diagram types, as one might do when one combines structural and behavioral elements (e.g., showing a state machine nested inside an internal structure). Consequently, the boundaries between the various kinds of diagram types are not strictly enforced.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • So in the Object Diagram I can leave out Controller and Sensor class definitions and leave the 3 objects and it will be fine as long as I provide the Class Diagram? – DonnellyOverflow Feb 04 '16 at 10:48
  • The "type" of the diagram is almost irrelevant. You can legally put anything in almost any diagram (with few exceptions) as long as it conveys what you try to express. – qwerty_so Feb 04 '16 at 11:02
  • So how is something like this marked as coursework, if there are no concrete rules? – DonnellyOverflow Feb 04 '16 at 11:44
  • Not really. The UML spec states explicitly that you can mix anything into any diagram type (almost, there are a few exceptions). – qwerty_so Feb 04 '16 at 12:21
  • See my addition in the answer. – qwerty_so Feb 04 '16 at 12:32
  • But my advice, before moving to object diagram, It is better to draw class diagram. Because If we identify the classes of the system that we are going to develop, it is easy to identify objects – dulaj sanjaya Jul 14 '16 at 12:08
  • @dulajsanjaya It depends on the way you proceed. When developing from scratch you first create classes. If you RE something, you use the (existing) objects. But even in the first class you often need objects to show some more concrete application of the design. – qwerty_so Jul 14 '16 at 12:28
  • @ThomasKilian Yes, you are correct. I only thought about developing from scratch.thanks – dulaj sanjaya Jul 14 '16 at 13:25