Modeling Behavior: An Overview
Modeling Behavior: An Overview
Up to this point in the course you have learned to ask what exists: what data the system stores, what entities relate to which, what actors need which use cases. Those are structural questions. Now we shift to a different and equally important set of questions: what happens, in what order, under what conditions? These are behavioral questions, and UML gives us a dedicated family of diagrams to answer them.
This lesson maps that landscape — the full UML diagram taxonomy — so that every diagram you build in the coming lessons has a clear place in the picture. Think of it as the navigator's chart before you sail into any one territory.
Structural vs Behavioral Diagrams
The fourteen standard UML diagram types split neatly into two camps.
Structural diagrams describe the static architecture of a system: its building blocks and the permanent relationships among them. They answer: "What does the system consist of?" The analyst uses these to model data, classes, components, and deployment topology. The key examples you have already met are:
- Class diagram — entities, attributes, operations, and relationships.
- Use case diagram — actors and the functional capabilities they interact with.
- Component / Deployment diagrams — how code modules and hardware nodes are organized.
Behavioral diagrams describe how a system moves through time. They answer: "What does the system do, and how does it do it?" This tutorial concentrates on the three most useful behavioral diagrams in everyday analysis work:
- Sequence diagram — the precise back-and-forth of messages between participants over time.
- Activity diagram — the flow of control and data through a process, including branches and parallel work.
- State machine diagram — the discrete states an object passes through and the events that drive transitions.
The UML Diagram Map
The diagram below organizes the full UML taxonomy. The three diagrams covered in this tutorial are highlighted in green.
The Question Each Diagram Answers
Choosing the wrong diagram is one of the most common mistakes junior analysts make. The following table gives you a fast decision rule. Commit it to memory — you will use it every time you sit down to model.
A Running Example: The Online Bookstore
Throughout this tutorial we will model the same system from three behavioral angles: an online bookstore where customers browse, order, and pay for books. This lets you directly compare the three diagram types side by side.
Here is a quick snapshot of the same "Place Order" scenario told three different ways:
- Sequence diagram view: Customer sends
addToCart()to Cart; Cart sendscheckStock()to Inventory; Inventory replies; Cart replies to Customer with confirmation. - Activity diagram view: Customer browses catalogue → selects item → system checks stock → [in stock?] yes → adds to cart → customer checks out → payment processed → order confirmed.
- State machine view (Order object): Order starts in
Draft→ on payment: transitions toConfirmed→ on dispatch: transitions toShipped→ on delivery: transitions toDelivered→ on return request: transitions toReturned.
Each view is correct. Each is incomplete on its own. Together they give you, and any developer or tester reading the specification, a complete behavioral picture.
How Structural and Behavioral Diagrams Work Together
The two families are not rivals — they are complementary layers of the same model. A well-written system specification pairs them deliberately:
- The class diagram tells you that an
Orderhas attributesstatusandtotal. The state machine tells you the legal values ofstatusand the rules for changing it. - The use case diagram tells you that a
Customercan Place Order. The sequence diagram tells you the exact messages exchanged to make that happen. - The class diagram identifies the
PaymentServicecomponent. The activity diagram shows when and why it is invoked in the order workflow.
When Does the Analyst Draw Behavioral Diagrams?
In a typical project lifecycle the behavioral diagrams appear at these moments:
- During requirements analysis — draft activity diagrams to agree on the as-is business process and the to-be process with stakeholders. These are communication tools first, precision tools second.
- During system design — draw sequence diagrams for every significant use case scenario. This is where the analyst hands off a precise, unambiguous contract to developers.
- Whenever an object has a lifecycle — draw a state machine for any entity that can be in one of several clearly distinct states (Order, Appointment, Library Book, Patient Record).
- During review and testing — use sequence diagrams to trace a defect back through the message chain; use state machines as test oracles to verify that illegal state transitions are blocked.
With this map in hand you are ready to go deep. The next lesson introduces sequence diagrams: their core notation, lifelines, messages, and activation boxes — the machinery behind the most widely used behavioral diagram in professional systems analysis.