Search code examples
classumlenumerationcomposition

Is the composition relationship correct between a class and an enumeration?


Because the unique instances of an enumeration lives during all the lifecycle of the application, I can say that there will be no composition relationship between a class and an enumeration.

enter image description here

Is what I say correct ?


Solution

  • No. That is simply contra-dictionary/nonsense. An enum is just one out of many. A composition is (as the name says) composed of multiple things. What you need here is a simple dependency which goes from MyClass to MyEnum. Not more.