I have a class which has an inner (nested) class. I have shown this relationship between the two classes in my class diagram. However, I am also using the inner class within the outer class... do I show another relationship for this or is the containment relationship enough?

  • What's the point of the inner class if another class outside of its parent is calling it? If other classes are calling your inner class you should make that inner class its own class because the parent of this class is not the only one who talks to it.
    – Luminous
    May 8, 2015 at 19:52
  • @Luminous sorry I meant to say that the inner class is being used in the outer class
    – Shahzad
    May 8, 2015 at 19:56

2 Answers 2


I would say no. You don't have to specify another relationship.

Inner classes AFAIK are implied to be used by their container. That's why they're an inner class. No one else needs to know about this class and no one has a use for it. This inner class is separate from it's containing object because it's different from the containing object, yet the container has an explicit need for this class and only this object has this need. Therefore, specifying a relationship between the containing class and inner class is enough to inherently imply these two classes are communicating with each other.

If the container class and inner class WEREN'T communicating with each other or worse yet, another object was calling directly to the inner class would show a clear design flaw of ever having this class as an inner class because its design purpose of being an inner class was not being correctly fulfilled.

If you wanted to go deeper in your design at some point you'd specify how the containing class is using the inner class and not just specify the container is using this inner class.


From The Unified Modeling Language User Guide (Booch, Rumbaugh, Jacobson) association is "a structural relationship that describes a set of links, in which a link is a connection among objects".

Aggregation is "a special form of association that specifies a whole-part relationship between the aggregate (the whole) and a component (the part)."

Finally, usage is "a dependency in which one element (the client) requires the presence of another elements (the supplier) for its correct functioning or implementation."

Given that, aggregation implies usage, so it's not necessary to depict it separately for an inner class relationship.

  • 1
    An inner class is not an aggregate of the outer class, so your reasoning is formless. May 8, 2015 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.