Question

According to my professor, one of the following relationships cannot be modeled in an object instance diagram:

  • Association
  • Composition
  • Generalization

I made the argument that the association could not be modeled in an object instance diagram, since that is more abstracted and is typically for a class diagram, while the other two are more concrete. However my TA told me I was wrong, and did not offer additional clarification.

I have read this post and looked up this page. Any guidance is appreciated.

Was it helpful?

Solution

Association and Composition make sense for objects, as well as classes. An object may use another (Association), and an object may contain another (Composition).

But you can only Generalize a base class to create a derived class. It's not possible for one object to be a Generalization of another object. If the base class isn't abstract, it's possible to have objects of both the based and derived classes, but there's still no sense that the derived object inherits from the base object; it still inherits from the base class.

OTHER TIPS

It might help to remember that classes don't really exist in the real world (they exist in our mental models), but objects do exist. So, when I'm using a UML object diagram, I'm showing things that are instances, usually of real-world things.

For example, if I say a Student is a Person, it's a generalization relationship. That relationship exists mentally, and you can show it in a UML class diagram.

enter image description here

But if I'm talking about a person named Jane Doe born on July 14, 2002, there is only one object, although she may be a Person and a Student. There are not separate objects in the real world if a person is also a student. If the purpose of the diagram is to speak of the object as a Student, then you would show that in the diagram. But it makes no sense to show a relationship to Person, since it's not an object (but a class):

enter image description here

On the other hand, with association and composition (aggregation), you can show in the object diagram that Jane is associated with her university (a real, separate object), and that she has a student ID card (a real, separate object).

enter image description here

Finally, class and object diagrams complement each other. It's not possible to show concrete cases in class diagrams, just as it's not possible to show generalizations in object diagrams. They work on different levels of abstraction.

Licensed under: CC-BY-SA with attribution
scroll top