Search code examples
umlassociationsaggregationclass-diagram

Can services be represented like aggregation relationship in UML?


There is service java class which uses another service class internally. They are completely independent classes of each other. They are simple Spring beans:

public class Service1 {
  ...
}

public class Service2 {
  @Bean
  private Service1 service1;
  ...
}

I want to create UML diagram where they are shown. I want to show relationship between them. Is it a best or normal practice to show relationships of such classes like aggregation? Is it correct to do so?

Aggregation


Solution

  • My famous citation of p. 110 UML 2.5

    shared | Indicates that the Property has shared aggregation semantics. Precise semantics of shared aggregation varies by application area and modeler.

    So, go ahead. Use it, but document it. Or use a simple association. I'd prefer the latter.