Search code examples
umlclass-diagram

Object diagram with infinite number of objects


Some time ago I found an example of a class diagram (with a finite number of classes) so that any object diagram can be derived only with an infinite number of objects. I tried searching for this case, but couldn't find it. I don't think that such diagrams have any practical use, but I found it fascinating, because from university I thought that this isn't possible.

Can you give an example of a class diagram such that any object diagram will require an infinite number of objects?


Solution

  • The simplest example I can think of:

    composite with at least one part

    Since every Thing must have at least one part, the chain of parts goes on to infinity. There can be no loops in this chain, because

    UML 2.5.1: Compositions may be linked in a directed acyclic graph