0.3.9 Contrasting UML Object and Activity Diagrams

Two Diagrams Can Describe the Same System in Different Ways

You have now worked with two UML diagram types:

Both can describe a soccer system.

They answer different questions.

An object diagram focuses on:

What specific things exist, what values do they have, and how are they related?

An activity diagram focuses on:

What happens, in what order, and which path is followed?

Choosing the right diagram begins by identifying which question you are trying to answer.

Object Diagrams Show a Snapshot

Consider this soccer state:

Plain text
player1 : Player
-------------------------
name = "Jordan"
isAvailable = true
Plain text
team1 : Team
-------------------------
name = "Wildcats"

with a relationship connecting player1 to team1.

This model communicates specific objects and state.

It can tell you:

It does not primarily tell you the sequence of actions that caused this state.

Activity Diagrams Show Flow

Now consider this process:

Plain text
Start
  ↓
Read player availability
  ↓
Is player available?
  ├─ [yes] → Add to available list
  └─ [no]  → Continue
               ↓
          Display roster
               ↓
              End

This model communicates behavior.

It can tell you:

It does not primarily describe all the field values inside player1.

Ask “What Exists?” or “What Happens?”

This is a useful shortcut.

Use an object diagram when the important question is:

What exists in this snapshot?

Use an activity diagram when the important question is:

What happens next?

Those questions are not perfect definitions, but they are useful when choosing a diagram at this stage of the course.

The Same Information Can Appear Differently

The Boolean value:

isAvailable = true

could appear as state inside an object diagram.

An activity diagram could use the meaning of that state to choose a path.

Object-diagram view:

Plain text
player1 : Player
-------------------------
isAvailable = true

Activity-diagram view:

Plain text
Is player available?
  ├─ [yes] → Add to list
  └─ [no]  → Continue

The two diagrams are related, but they are not interchangeable.

One emphasizes the object's state.

The other emphasizes how a decision affects flow.

A Diagram Should Not Try to Do Every Job

Imagine an activity diagram whose action nodes are filled with every field value for every soccer object.

The process would become difficult to follow.

Imagine an object diagram whose boxes are arranged in a long chain to imply a sequence of events.

The timing and flow would be ambiguous.

A model becomes clearer when its representation matches its purpose.

Object Diagrams Emphasize Nouns and State

Object diagrams often focus attention on specific things such as:

and their current information.

They are useful for discussing:

Activity Diagrams Emphasize Actions and Paths

Activity diagrams often focus attention on verbs:

and on how those actions connect.

They are useful for discussing:

Both Are Abstractions

Neither diagram should include everything about the soccer system.

The object diagram includes the objects, values, and relationships needed for its purpose.

The activity diagram includes the actions and paths needed for its purpose.

Abstraction applies to both.

The question is always:

Which information is needed for this model to answer the question it was created to answer?

Models Can Support One Another

A technical team might use both diagrams.

An object diagram could establish that:

player1.isAvailable = true

An activity diagram could show what the system does when the availability condition is true.

Later, C# code can implement related state and behavior.

The models do not have to contain identical information.

They provide complementary views of the same computerized system.

Choose the Diagram by the Question

Keep this distinction available as the course continues:

If you need to understand... Useful diagram
specific objects and their current values UML object diagram
relationships among specific object instances UML object diagram
ordered actions in a process UML activity diagram
a decision and its possible paths UML activity diagram

As you encounter new UML diagram types later, the same principle will matter.

Each model exists to answer a particular kind of question.