337

I have recently been studying UML and drawing simple diagrams with ordinary plain arrows between classes, but I know it's not enough. There are plenty of other arrows: generalization, realisation and etc. which have meaning to the diagram reader.

Can I get an explanation on each arrow (ordinary, plain, dotted, diamond-filled, diamond)?

It would be the best if it will have some code examples for them.

2

8 Answers 8

554

Here's some explanations from the Visual Studio 2015 docs:

UML Class Diagrams: Reference: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/modeling/uml-class-diagrams-reference

UML class diagram

5: Association: A relationship between the members of two classifiers.

5a: Aggregation: An association representing a shared ownership relationship. The Aggregation property of the owner role is set to Shared.

5b: Composition: An association representing a whole-part relationship. The Aggregation property of the owner role is set to Composite.

9: Generalization: The specific classifier inherits part of its definition from the general classifier. The general classifier is at the arrow end of the connector. Attributes, associations, and operations are inherited by the specific classifier. Use the Inheritance tool to create a generalization between two classifiers.

Package diagram

13: Import: A relationship between packages, indicating that one package includes all the definitions of another.

14: Dependency: The definition or implementation of the dependent classifier might change if the classifier at the arrowhead end is changed.

Realization relationship

15: Realization: The class implements the operations and attributes defined by the interface. Use the Inheritance tool to create a realization between a class and an interface.

16: Realization: An alternative presentation of the same relationship. The label on the lollipop symbol identifies the interface.

UML Class Diagrams: Guidelines: http://msdn.microsoft.com/library/dd409416%28VS.140%29.aspx

Properties of an Association

Aggregation: This appears as a diamond shape at one end of the connector. You can use it to indicate that instances at the aggregating role own or contain instances of the other.

Is Navigable: If true for only one role, an arrow appears in the navigable direction. You can use this to indicate navigability of links and database relations in the software.


Generalization: Generalization means that the specializing or derived type inherits attributes, operations, and associations of the general or base type. The general type appears at the arrowhead end of the relationship.

Realization: Realization means that a class implements the attributes and operations specified by the interface. The interface is at the arrow end of the connector.

Let me know if you have more questions.

7
  • 1
    Nice reference but to me a Menu -> MenuItem has the same relation like a Order -> OrderItem so both of them are Compositions. Commented Jun 28, 2013 at 10:53
  • 4
    That both only mean, that the order item belongs to an order and can't be moved, whereas the Menu Item can be adjustable - the user may can to change the position of Menu Item. It is the solution chosen. Why not?
    – Gangnus
    Commented Feb 3, 2014 at 13:17
  • 3
    @JMD, The order items can be moved as well. Composite aggregation is defined in the UML spec as follows: Composite aggregation is a strong form of aggregation that requires a part object be included in at most one composite object at a time. If a composite object is deleted, all of its partinstances that are objects are deleted with it. A part object may (where otherwise allowed) be removed from a composite object before the composite object is deleted, and thus not be deleted as part of the composite object. Commented Jan 26, 2016 at 10:43
  • 2
    @aGer Thanks, I've updated the topic and image links. Commented May 22, 2017 at 16:39
  • 1
    Funny that Mickeysoft it labeled a major reference for UML. They are member of OMG but definitely just one of them. Besides that the rendering of classes does not meet the standard (I'll gracefully ignore the drop down icons inside). The source for UML is found at omg.org/spec/UML/2.5.1/About-UML
    – qwerty_so
    Commented Oct 29, 2021 at 20:26
49

A nice cheat sheet (http://loufranco.com/wp-content/uploads/2012/11/cheatsheet.pdf):

It covers:

  • Class Diagram
  • Sequence Diagram
  • Package Diagram
  • Object Diagram
  • Use Case Diagram

And provides a few samples.

Class Diagram Elements, like parent to child relationship , subclass relationship, interface and implementor, plus Sequence Diagram Elements

4
  • 5
    I've been looking for exactly this for the last 30 minutes. I know the concepts, I just forget the symbols.
    – aclave1
    Commented Sep 17, 2014 at 20:32
  • 1
    The drawback with this presentation is that it uses the UML exception flow connector to mark single points of interest. I don't think that's a good idea.
    – qwerty_so
    Commented Oct 29, 2021 at 20:18
  • @qwerty_so , you mean like this? i.imgur.com/Q68VxTz.png I see what you mean... Commented Oct 30, 2021 at 21:12
  • 1
    Exactly that. It would probably be better to use some non-UML notation (like Mickeysoft did with the circled numbers) to indicate/explain the single arrows rather than using another UML arrow (I know they use a lot already).
    – qwerty_so
    Commented Oct 31, 2021 at 8:00
15

My favourite UML "cheat sheet" is UML Distilled, by Martin Fowler. It's the only one of his books that I've read that I do recommend.

4
  • 2
    Interesting, I quite liked Refactoring. Is that one you have opinions on.
    – djna
    Commented Dec 9, 2009 at 14:27
  • Yes, I found it all a bit obvious, and didn't like the concentration on Java. Also, please don't take my answer as saying that his other books are rubbish.
    – anon
    Commented Dec 9, 2009 at 14:30
  • Fowler's book also has a cheat sheet on the inside of the book covers. Really good for starting out, especially as your next question will be what direction do the arrows go? Commented Dec 12, 2009 at 16:48
  • 32
    185 pages seems a little excessive for a "cheat sheet"!
    – cdyson37
    Commented Jul 14, 2015 at 13:35
11

For quick reference along with clear concise examples, Allen Holub's UML Quick Reference is excellent:

http://www.holub.com/goodies/uml/

(There are quite a few specific examples of arrows and pointers in the first column of a table, with descriptions in the second column.)

1
  • I liked his very first example and was hoping hew would go incrementally on same lines with basics, but it is a good read
    – killjoy
    Commented Sep 29, 2018 at 15:30
7

A very easy to understand description is the documentation of yuml, with examples for class diagrams, use cases, and activities.

1
  • 1
    Probably the best UML-for-idiots while going down this list; note: this site also lets you draw your own UMLs for free (5).
    – killjoy
    Commented Sep 29, 2018 at 15:33
7

The accepted answer being said, It is missing some explanations. For example, what is the difference between a uni-directional and a bi-directional association? In the provided example, both do exist. ( Both '5's in the arrows)

If looking for a more complete answer and have more time, here is a thorough explanation.

5

Aggregations and compositions are a little bit confusing. However, think like compositions are a stronger version of aggregation. What does that mean? Let's take an example: (Aggregation) 1. Take a classroom and students: In this case, we try to analyze the relationship between them. A classroom has a relationship with students. That means classroom comprises of one or many students. Even if we remove the Classroom class, the Students class does not need to destroy, which means we can use Student class independently.

(Composition) 2. Take a look at pages and Book Class. In this case, pages is a book, which means collections of pages makes the book. If we remove the book class, the whole Page class will be destroyed. That means we cannot use the class of the page independently.

If you are still unclear about this topic, watch out this short wonderful video, which has explained the aggregation more clearly.

https://www.youtube.com/watch?v=d5ecYmyFZW0

1

If you are more of a MOOC person, one free course that I'd recommend that teaches you all the in and outs of most UML diagrams is this one from Udacity: https://www.udacity.com/course/software-architecture-design--ud821

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