UML for Android Engineers
Learn how to draw UML diagrams to document your Android applications. By Massimo Carli.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
UML for Android Engineers
50 mins
- Getting Started
- Understanding UML
- Deciding What to Document
- Creating Use Case Diagrams
- Creating Complex Use Case Diagrams
- Creating a Deployment Diagram
- Creating a Dependency Diagram
- Creating Class Diagrams
- Representing Relations
- Understanding Aggregation
- Representing Abstract Classes
- Representing Static Members in UML
- Representing Just What You Need: Another Example
- Using Stereotypes
- Creating Dynamic UML Diagrams
- Representing Objects
- Understanding Collaboration Diagrams
- Understanding Sequence Diagrams
- Understanding Asynchronous Invocations
- Understanding State Diagrams
- Diving Deeper Into State Diagrams
- Where to Go From Here?
Understanding State Diagrams
The state is a fundamental concept in modern Android development. You can define a state as a set of values an item has in a specific instant. A typical example in Android is about Activity
that can be in different states that define the activity lifecycle. The Lifecycle Architecture Component defines the states you can find in the following state diagram:
This is a very simple state diagram that contains some of the main symbols you can use:
- The full circle represents the initial state. This is the state of your item when it starts to exist. As you see in the diagram, once you exit that state, you never return.
- Your system remains in the same state until “something happens”, and then it moves to another state, represented by a rectangle with rounded corners and its name inside.
- As you learned, the system moves from one state to another when “something happens”. This could be anything, like the invocation of a method or some asynchronous operation. In the diagram, the transition from CREATED to STARTED happens when the ON_CREATE happens.
- In a state diagram, you represent the final state with a circle with a smaller full black circle inside. As the name says, this is the final state, and you cannot exit from it.
There are other things you can represent in a state diagram and it’s worth having a quick look.
Diving Deeper Into State Diagrams
To learn more conventions about state diagrams, look at the following one:
This diagram contains two more pieces of information. In it, you:
- Represent a state with a round-cornered box split into two parts. The upper contains the name of the state. The lower contains the action that the system does while in that state. For instance, the system displays a spinner while in the Loading state.
- Know that you can move from one state to another when “something happens”. Most of the time, it’s because of a message or method invocation with a condition that you represent with [condition]. This means that the transition happens if the event happens and the [condition] is true.
State diagrams are one of the most useful UML diagrams you can use, but, as always, be careful to focus on a single aspect of the system you’re describing.
Where to Go From Here?
Great job completing the tutorial! You learned how to create the most important UML diagrams for documenting your app. It’s fundamental to understand that UML is a language you can modify however you want, just as long as it’s easy to understand. Very complicated diagrams with a lot of symbols and details generally do more harm than good and introduce confusion rather than clarity.
You can checkout this dedicated UML website to learn more about UML.
We hope you enjoyed this tutorial! If you have any comments or questions, feel free to join the discussion below.