Systems Modeling
Prerequisite Knowledge
This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.
Previously Covered in This Subject
- Requirements engineering — covered in Lecture 3 (Requirements Engineering)
- Requirements elicitation and analysis — covered in Lecture 3 (Requirements Engineering)
- Requirements specification and validation — covered in Lecture 3 (Requirements Engineering)
- Use cases — covered in Lecture 3 (Requirements Engineering)
This lecture is about modeling software systems: how graphical models are used to represent a system, why several different types of models are needed to represent it fully, and how those models are produced as part of requirements engineering and then refined during design. You will look at the four perspectives from which a system can be modeled — the context of the system, the interaction between its components, the structure of the system, and its behavior — and at the main diagram types of the Unified Modeling Language (UML) that express those perspectives.
What you will build here. The lecture is a complete tour of the modeling toolkit, arranged in the same order you will use it in a real project:
- Why model at all — what an abstract model is, how modeling fits inside requirements engineering, and the four perspectives that force you to draw several different diagrams (section 4.1).
- How models get used — models built for discussion, models built for documentation, and models built to generate code; each use sets a different bar for completeness and correctness (section 4.2).
- Context models — deciding where the system ends and its environment begins, and drawing the context diagram that shows the other systems it depends on (section 4.3).
- Activity diagrams — modeling a business process as a flow of activities, with decision guards, joins, and parallel forks (section 4.4).
- Interaction models — use case diagrams and sequence diagrams that show who talks to whom, in what order (section 4.5).
- Structural models — class diagrams with associations, multiplicity, generalization, and aggregation (section 4.6).
- Behavioral models — state diagrams that show how a system responds to events (section 4.7).
The running example. Throughout the lecture, one realistic system ties every diagram type together: a mental health care patient information system that manages information about patients attending mental health clinics and the treatments prescribed for them. The same system is examined with context, activity, use case, sequence, and class diagrams, so you can see how the different perspectives fit together — and how the same real-world facts look different in each picture.
The two final sections collect the exam guidance the professor gave during the lecture (section 8) and the real-world industry applications of each modeling technique (section 9).
4.1 System Modeling: What It Is and Why We Do It
Hook. You cannot see a whole building from a single photograph — one shot shows the front, another the roof, another the floor plan. A software system is far harder to "see" than a building, because it does not exist yet when it is being planned. System modeling is how engineers get around that problem: they draw several different pictures of the system, each from a different viewpoint, and each deliberately incomplete. No single picture carries the whole truth — the pictures together do.
4.1.1 What System Modeling Is and Where It Fits
System modeling is the process of developing abstract models of a system, with each model presenting a different view or perspective of that system. In most software projects, system modeling means representing the system using some kind of graphical notation based on the various diagram types in the Unified Modeling Language (UML). It is also possible to develop formal models — mathematical models that accompany a detailed system specification — but the graphical route is the one we focus on here. The whole point of building these representations is to understand the system from several different perspectives that no single picture could provide.
The UML is the standard notation for this work, so it is worth knowing where it comes from. The Unified Modeling Language (a set of diagram types used to model software systems) grew out of object-oriented modeling work in the 1990s, when several similar object-oriented notations were merged into one. A major revision, UML 2, was finalized in 2004, and the language is now universally accepted as the standard way to develop models of software systems. The UML defines 13 diagram types in total — but, as the lecture will show, a handful of them cover the essentials of most systems, and those are the ones examined here. Variants such as SysML adapt the notation for modeling entire systems (including hardware), which shows how flexible the core idea is.
The models are developed as part of the requirements engineering process and are then elaborated during the design process. To position system modeling, recall what was covered in the previous lecture on requirements engineering: the requirements engineering process has three important activities — requirements elicitation and analysis, requirements specification, and requirements validation. During requirements elicitation and analysis you develop a variety of descriptions of the system, which may be graphical models, descriptive models, or mathematical models. These become part of the requirements specification, also called the requirements document, both at the user-requirements level and at the system-requirements level. So a class diagram of the mental health care system sitting inside its requirements document is not a decoration — it is one of the deliverables of the elicitation and analysis activity, and it is validated together with the rest of the document.
Models are used at three points in the life of a project, and the audience differs at each point:
- During requirements engineering — models help derive the detailed requirements for a system. This is where the models carry the analysis: what must the system do, and what must it not do?
- During design — models describe the system to the engineers who will implement it. The design models are refinements of the requirements models: more detail, more structure, closer to code.
- After implementation — models document the system's structure as well as its operation, so that people who did not build the system — maintainers, auditors, future teams — can understand it.
Why several models, not one. Each model type answers a different question about the system, and questions asked from different viewpoints cannot be answered by a single picture. One view asks what surrounds the system; another asks who talks to whom, and in what order; a third asks what the parts are and how they are related; the fourth asks how the system responds to events (section 4.1.4 works through all four). A diagram that is excellent at answering one of these questions is useless for the others — which is why a full system description is always a family of models, not one diagram.
4.1.2 Models of the Existing System and the New System
You may develop models of both the existing system and the system to be developed, and the two serve different purposes.
Models of the existing system are built during requirements engineering. You create them to showcase what you understood of the requirements gathered through interviewing, ethnography, user stories, scenarios, and the other elicitation techniques. They help clarify what the existing system does, and they can be used to focus a stakeholder discussion on its strengths and weaknesses. Suppose a clinic currently records patient consultations on paper forms. A model of that existing process — an activity diagram of the paper workflow — makes it concrete where the current system is slow (forms wait in trays) or risky (records misfiled), so the discussion about the new system starts from agreed facts rather than opinions.
Models of the new system are also created during requirements engineering, but their job is different: they help explain the proposed requirements to the various stakeholders. Later, software engineers use these models to discuss design proposals among themselves and to document the system for implementation.
The two kinds of model differ along every practical dimension, so keep them distinct:
| Dimension | Model of the existing system | Model of the new system |
|---|---|---|
| When it is built | During requirements elicitation and analysis | During requirements engineering, then refined in design |
| What it describes | The system as it is today, including its problems | The system as it should be after development |
| Primary audience | Stakeholders (to agree on problems and strengths) | Stakeholders (to explain proposals), then engineers (to design and implement) |
| Main use | Focus discussion on strengths and weaknesses | Explain proposed requirements; document for implementation |
There is an important direction here: the existing-system model is a starting point for analysis, and the new-system model is a commitment about what will be built. Mixing them up — drawing the new system in the shape of the old one without noticing — is one of the most common sources of "we automated our paper forms" projects that reproduce every old inefficiency.
4.1.3 An Abstraction, Not an Alternative Representation
A key distinction to hold on to: a system model is not a complete representation of the system. It is abstract, and it deliberately leaves out details so that the system is easier to understand from a particular perspective. In other words, the model is an abstraction of the system, not an alternative representation of it.
The difference matters. An alternative representation of a system should maintain all the information about the system being represented — nothing may be lost. An abstraction, by contrast, deliberately simplifies a representation or a design and selects the most salient characteristics, dropping the rest on purpose.
A familiar example: the slide deck used to teach this topic is essentially a representation of the entire topic of systems modeling, which is also covered by the courseware and the corresponding chapters of the textbooks and other sources. The slides for a particular topic are an abstraction — they capture the key points of the chapter, not the chapter itself. But if that chapter were to be translated into another language, the translation would be an alternative representation: it must maintain all the information exactly as it is presented in the original. That is the test that separates the two ideas.
Worked example: applying the abstraction test. For each item below, decide: is it an abstraction (some information deliberately dropped) or an alternative representation (all information preserved)? Then check your answer.
Item 1 — the lecture slide deck. The slides summarize the chapter: key points in, worked detail out. Information is dropped on purpose. Answer: abstraction.
Item 2 — an Italian translation of the chapter. The translator's goal is to keep all the information exactly as the English presents it. Answer: alternative representation — even though the words are different, the information content must be identical.
Item 3 — the London Underground map. It distorts distances and ignores every street; only the stations and lines remain. A passenger cannot use it to navigate above ground. Answer: abstraction — and deliberately so: the map is easier to use because the clutter is gone.
Item 4 — a high-resolution scan of a signed contract. Every word, every signature, every crease is copied. Answer: alternative representation — a legal document's meaning lives in its full content, so nothing may be lost.
Sense-check. The rule works in all four cases: if the purpose requires all information to survive, it is an alternative representation; if the purpose is served by selected information, it is an abstraction. A system model behaves like the Underground map — the trick is to choose which details to keep for the perspective you are drawing.
If the distinction still feels abstract, here is a second picture. A tourist map of a city is an abstraction: it shows the castle, the river, and the main squares, and it leaves out most side streets, because a visitor needs landmarks, not every alley. A photocopy of the complete street atlas is an alternative representation: every street appears, because a courier needs every route. Both are "the city" — but the map exists to make the city easy to grasp, while the atlas exists to make it fully recoverable. Where the analogy ends: a system model is not just a smaller copy of the system — it is a different kind of object (a picture in a notation) that stands in for the system for a limited purpose. You never mistake the map for the city, and you should never mistake the class diagram for the system.
4.1.4 The Four Modeling Perspectives
While performing the system modeling exercise you can develop models that represent the system from four different perspectives:
- External perspective — the context or environment of the system: the various other systems and subsystems that the system interacts with. This perspective answers "what is around the system, and what does it depend on?"
- Interaction perspective — the interactions between the system and its environment, or between the components of the system. This answers "who talks to whom, and in what order?"
- Structural perspective — the organization of the system, or the structure of the data processed by the system. This answers "what are the parts, and how are they connected?"
- Behavioral perspective — the dynamic behavior of the system and how it responds to events. This answers "what does the system do when an event occurs?"
Each perspective is expressed in the lecture by specific diagram types, which section 4.2.5 introduces in full:
| Perspective | Question it answers | Diagram types used |
|---|---|---|
| External | What surrounds the system, and what does it depend on? | Context diagrams, use case diagrams |
| Interaction | Who talks to whom, and in what order? | Use case diagrams, sequence diagrams |
| Structural | What are the parts and how are they connected? | Class diagrams |
| Behavioral | How does the system respond to events? | Activity diagrams, state diagrams |
All four perspectives get covered in this lecture, with the structural and behavioral ones receiving the most attention — a choice that reflects practice: most projects draw class diagrams and state diagrams as the core of their design, and use the other perspectives to check the system against its environment and its users.
Pitfalls in thinking about system modeling.
- Expecting one diagram to answer every question. A context diagram that shows the system's neighbors beautifully contains nothing about the order of interactions inside the system. Students often ask "which diagram do I draw?" — the answer is "several, one per perspective." Each is judged by the question it answers, not by completeness.
- Confusing "abstract" with "incomplete or wrong". Abstraction means dropping detail deliberately. A model that drops the wrong detail — the detail that matters for its purpose — is simply a bad model. The correctness bar is set by how the model will be used, which is the subject of section 4.2.
- Drawing the model after the decisions are made. The value of a model is that it forces you to think. A context diagram drawn after the system boundary was already locked in is a record of a decision that was made without the model's help.
- Confusing the model with the system. Nobody drives along the road on a road map. A class diagram is not the classes in the running program; it is a picture of them, and the picture is always simpler than the thing.
Recap + bridge. System modeling = building abstract graphical models of a system from several perspectives, as part of requirements engineering, to be refined during design. A model is an abstraction — it drops detail on purpose — not an alternative representation that keeps everything. The four perspectives (external, interaction, structural, behavioral) are the reason no single diagram suffices. Next, section 4.2 asks the practical question: how will the models you draw actually be used — because that determines how complete and how correct they must be.
Real-world connection. System models in the UML are the working language of requirements documents in regulated industries: health-care information systems, banking platforms, and embedded systems in cars and medical devices all ship with context, interaction, structural, and behavioral diagrams as part of their specifications. Regulators and auditors read these models, not the source code — the diagrams are often the only artifact that survives in human-readable form from early analysis. Where models are used to generate code (model-driven engineering, section 4.2.4), the same diagrams become the actual production input, which is why notation discipline stops being optional there.
4.2 How Graphical Models Are Used
Hook. The same box-and-line diagram can be a sketch on a whiteboard, an appendix to a system document, or the input to a code generator. It looks identical in all three places — but the demands placed on it are completely different. One version tolerates mistakes, one requires accuracy, and one punishes a single wrong arrow by generating broken code. This section explains how the intended use of a model sets its bar for completeness and correctness.
4.2.1 Notation Can Be Used Flexibly
When you develop system models you can often be flexible in the way the graphical notation is used — you do not always have to stick rigidly to the details of the notation, and you can use it informally. The amount of detail and rigor in a graphical model depends on how you intend to use it. There are three common ways graphical models are used in practice, and each one sets a different bar for completeness and correctness. It helps to keep repeating the underlying fact from the previous section: the model is not an alternative representation of the system; it is an abstraction of the system from a particular perspective.
Think of the three uses as three different contracts, summarized here and developed in the rest of this section:
| Use | Completeness required | Correctness required | Notation discipline |
|---|---|---|---|
| 1. Stimulate and focus discussion | Incomplete is fine (cover the key points) | Low — the diagram is a shared sketch | Informal — box-and-line allowed |
| 2. Document an existing system | Incomplete is fine (only the parts you need) | High — must accurately describe those parts | Proper use of the notation |
| 3. Generate an implementation (MDE) | Complete — every detail the code needs | High — the model is the source of truth | Strict — symbol precision is a compile-time contract |
The progression is one-way in practice: a discussion model may grow into documentation, and documentation may be refined into an implementation model — but never the reverse. The more formal the use, the more care every symbol needs.
4.2.2 Use 1: Stimulating and Focusing Discussion
The first use of a graphical model is as a way to stimulate and focus discussion about an existing or proposed system, among the software engineers and the stakeholders. Models used this way may be incomplete as long as they cover the key points of the discussion, and they may use the modeling notation informally — a box-and-line diagram, or even UML models that are incomplete. This is how models are normally used in agile methods: as a means of discussion and clarification, building shared understanding between the developers and the system stakeholders, or between the developers themselves.
The value of the discussion model is not its accuracy but its sharedness. When the clinic's receptionists point at a box on a whiteboard and say "no, the appointment system does that first," the model has done its job — it has made the disagreement visible. Because the model is a means to a conversation, drawing it wrong is not a disaster; the conversation repairs it. What would defeat the purpose is a diagram so cluttered with detail that nobody can react to it, or a drawing session so slow that the discussion dies while the notation is being perfected.
4.2.3 Use 2: Documenting the System
The second use is to document an existing system — one you have observed and collected information about during requirements elicitation and analysis. Documentation models do not have to be complete either, because you may need models only for the parts of the system where discussion and clarification were required. But documentation models do have to be correct: they should use the notation properly and be an accurate description of the particular part of the system they cover. Incomplete is acceptable; inaccurate is not.
The completeness-versus-correctness contrast (a key distinction of the lecture). The two documentation roles look similar, but they set different bars:
- A discussion model (section 4.2.2) may be incomplete and informal. Its job is to make the conversation concrete. A hand-drawn box-and-line diagram of the clinic's workflow that omits the archiving step is fine if the conversation is about appointments.
- A documentation model may also be incomplete — you are allowed to document only the parts of the system that needed clarification — but it must be correct: the notation used properly, the facts accurate. A documentation model that claims the archive step does not exist, when it does, is a defect, because someone will later rely on that document.
The test to remember: incomplete is acceptable; inaccurate is not. The distinction matters because documentation outlives the conversation — the people reading the document were not at the whiteboard.
4.2.4 Use 3: Model-Driven Engineering
The third use is as a detailed system description that can be used to generate a system implementation. This is called model-driven engineering (MDE), and it is part of the model-based development process: you convert the UML models into certain skeleton code, generating code from precise UML models that are both complete and correct. Because the models now feed code generation, you have to be very careful with the symbols and the notation — there is a big difference between a simple connector (a line between two entities) and a line with an arrow between two entities, and the two carry different meanings in a UML model, as you saw with the use case diagram in the previous lecture. What is informal fun in the discussion use becomes a compile-time contract in this use.
The shift in mental model is the important part. In the first two uses, the diagram is about the system — it describes something that exists or will exist. In MDE, the diagram becomes the system: the UML models are the principal output of the development process, and the programs that run on a hardware or software platform are generated automatically from them. Proponents of MDE argue that this raises the level of abstraction in software engineering, so engineers no longer have to worry about programming-language details or the specifics of execution platforms. In practice, MDE is built on the idea of model-driven architecture (MDA), proposed by the Object Management Group (OMG): you create a high-level platform-independent model (PIM) of the system's operation, and transform it into platform-specific models (PSMs), one per target platform (for example, one PSM for a Java application server and another for an embedded controller), from which the implementation is generated.
This is why notation discipline is absolute in this use. In the UML, a plain line and an arrowed line are different facts: in a use case diagram, for example, a plain line says "this actor is involved in this use case," while arrowheads would claim a one-way direction of message flow. A generator has no judgment — it will faithfully produce whatever the symbols say, including the wrong thing. When the model is the contract, every symbol is a compiler directive.
4.2.5 The UML Diagrams Covered in This Lecture
A handful of UML diagram types are enough to cover the four perspectives from section 4.1.4, and these are the diagrams examined in this lecture:
- Activity diagrams — show the activities involved in a process or in data processing: from the input to the output of a process, with all the transformations in between.
- Use case diagrams — show the interaction between a system and the entities in its environment, or the other systems in its environment (these were introduced in the previous lecture).
- Sequence diagrams — show the interactions between the actors and the system, and also between the system components.
- Class diagrams — show the object classes in the system and the associations between these classes.
- State diagrams — show how the system reacts to internal and external events.
- Context diagrams — show the system within the context of the other systems in its environment.
The lecture proceeds through these in the same order: context models first, then interaction models, then structural models, then behavioral models.
Recap + bridge. Graphical models serve three uses — discussion (informal, incomplete is fine), documentation (must be correct, may be incomplete), and model-driven engineering (must be complete and correct because the model generates code). One fact travels through all three: the model is an abstraction, and its bar for completeness and correctness is set by its use, not by the notation. The rest of the lecture works through the diagrams in their natural order, starting with the first thing you must decide about any system — where it ends and its environment begins (section 4.3).
Real-world connection. Discussion models are the daily currency of agile teams — whiteboard sketches, index cards, and informal box-and-line diagrams that build shared understanding without ceremony. Documentation models are what keep regulated systems maintainable: avionics and medical-device projects are required to keep system documents that accurately describe the implemented system, even when they describe only parts of it. Model-driven engineering is used where code volume is enormous or platforms change quickly — for example, in the automotive industry, where platform-specific code for different car models is generated from shared platform-independent models.
4.3 Context Models
Hook. Before you draw a single box of the new system, you must answer a question that sounds trivial and is not: where does the system end? Is the banking app responsible for checking the account balance, or is that another system's job? The answer decides what the project builds, who owns what data, and even whose jobs change. This section shows how system boundaries are decided — and why the decision is never purely technical.
4.3.1 Deciding the System Boundary
At an early stage in the requirements specification of a system you should decide on the system boundaries: what will be part of the system to be developed and what will not, what will be done manually and what will be done by other systems. This involves working with the system stakeholders to decide what functionality should be included in the system and what processing and operation should be carried out in the system's operational environment. You may decide, for example, that automated support for some business process should be implemented in the software being developed, but that other processes should stay manual or be supported by different systems.
During this process you should also look for possible overlaps in functionality with existing systems and decide where new functionality should be implemented. These decisions should be made early in the process, because they limit the system costs and the time needed for understanding the system requirements and design.
Why "early"? Because the boundary is the single most expensive decision in the project. If the boundary is drawn too small, the system misses functionality the stakeholders need, and the project must later integrate other systems — or worse, extend the boundary mid-design, when the requirements and architecture have already been organized around the smaller scope. If the boundary is drawn too large, the system must own functionality that already exists elsewhere, duplicating it and doubling maintenance. The boundary decision is also what bounds the requirements understanding: the smaller the system, the less of the organization's operation you must analyze and specify.
In some cases the boundary between the system and its environment is relatively clear. If you are building a banking system that automates the customer-facing operations, for example, then certain backend operations are simply not part of the current system. And when an automated system is replacing an existing manual — or even computer — system, the environment of the new system is usually the same as the environment of the existing system. The new system steps into the shoes of the old one: the same banks, the same reporting agencies, the same customers — only the automation inside the boundary changes.
In other cases there could be various changes, and you have to decide what constitutes the boundary between the system and its environment, especially when you are developing a new system during the requirements engineering process. A completely new system, unlike a replacement, has no existing environment to inherit — every connection to another system is a decision, not a fact.
4.3.2 The Mental Health Care System Example
Consider the running example used throughout this lecture: a mental health care patient information system, intended to manage information about patients attending mental health clinics and the treatments that have been prescribed for them. In developing the specification for this system you have to decide whether the system should focus exclusively on collecting information about consultations, using other systems to collect personal information about patients — or whether it should collect personal patient information by itself.
There is a real trade-off here. The advantage of relying on other systems is that you avoid duplicating data: the patient's personal details live in one place, maintained by one owner. The major disadvantage is that other systems may make access to information slower, and if those systems are not available, it may be difficult or even impossible to use the system you are designing.
Let the trade-off breathe, because it is the template for almost every boundary decision. On one side: no duplication. If the patient's name, address, and phone number live only in the general patient record system, then they are maintained once, by the team that owns that system, and every other system reads them from there. The mental health care system never has to worry about stale or conflicting personal data. On the other side: dependency. Every request for patient information now involves a call to another system — slower than a local lookup, and if the other system is down, the mental health care system cannot do its own core work. Notice that the trade-off is not about features; it is about where the truth lives and who depends on whom.
Configurable systems as a way out (professor's approach for diverse user bases). Sometimes the user base — and the stakeholder set — is quite diverse, with a wide range of different system requirements. In that situation you may decide not to define the boundaries explicitly at all. Instead you can decide to develop a configurable system that can be adapted to the needs of different users; the mental health care system, for example, could be configured to interact with different sets of other systems depending on the installation.
This was exactly the approach adopted for the iLearn systems, a learning environment whose users range from very young children who cannot read, through young adults, their teachers, and school administrators. Because these groups need different system boundaries — the children need a walled garden, the administrators need reporting hooks into every school system — a single fixed boundary could not work. For that reason, the specification defined a configuration system: the boundary is set at deployment time, per installation, rather than at design time. The lesson: the boundary is a requirement like any other, and it can be parameterized.
4.3.3 Boundaries Are a Judgment, Not an Objective Fact
Here is a point worth sitting with: the definition of a system boundary is not an objective, value-free judgment. Various social and organizational concerns influence where the boundary is placed, and the choice carries social and organizational consequences. It can even be a political judgment: there may be pressures to develop boundaries that increase or decrease the influence — or even the workload — of different people in different parts of the organization. When you draw the boundary, someone's job changes; expect that to be a negotiation, not a technical computation.
This is not cynicism; it is a warning about where boundary pressures actually come from. A boundary may be deliberately positioned so that the complete analysis process can be carried out on one site (keeping control in one place); it may be chosen so that a particularly difficult manager need not be consulted (excluding a stakeholder's scope of work); and it may even be positioned so that the system cost is increased and the development division must then expand to design and implement it. All of these are real behaviors observed in organizations — the boundary is a decision about work and power, and the people whose work or power it affects will push back.
What this means for the engineer. When you draw the system boundary, you are not just placing a line on a diagram — you are allocating work, data ownership, and influence inside an organization. Three practical consequences:
- Expect negotiation, not acceptance. Stakeholders will argue for or against including functionality not on technical merit but on what it does to their team. Do not treat the argument as a misunderstanding to be corrected; treat it as a real force to be designed around.
- Surface the nontechnical reasons. If the only way to explain a boundary choice is "because that keeps the analysis on one site," say so. Hidden political boundaries produce requirements that make no sense technically and fail later.
- Document the choice and its alternatives. A boundary decision record — "we put personal data outside the system because the patient record system already owns it; if that system's availability drops below target, this decision must be revisited" — turns an invisible judgment into a reviewable decision.
4.3.4 Context Diagrams
Once you have made some decision on the boundaries of the system, part of the analysis activities is the definition of the context and of the dependencies the system has on the other systems and entities in its environment. The first step of this activity is normally a simple context diagram — a box-and-line diagram. In the mental health care example, the context diagram shows the mental health care system interacting with a set of other systems: the patient record system, the admission system, the prescription system, the appointment system, the health care statistics system, and the management reporting system.
The drawing itself is simple: a box for the system being developed, a box for each system in its environment, and lines between them. The UML shows each system box with a stereotype — the kind of entity written between chevrons, for example «system» — so that a reader can tell at a glance that these are systems rather than, say, classes or components. In the mental health care context diagram, the mental health care system is connected to an appointments system and a more general patient record system with which it shares data, to systems for management reporting and hospital admissions, to a statistics system that collects information for research, and to a prescription system used to generate prescriptions for patients' medication.
Context models normally show that the environment includes several other automated systems, but they do not show the type of relationships between the system being specified and the systems in its environment. Those relationships matter, and they come in many forms. External systems might produce data for the system, take data from the system and consume it, or share data with the system. They might be connected directly, connected through a network, or not connected at all — functioning independently and transferring information as and when required. And these systems may be located together, or they may be geographically distributed, in different buildings or different places. All of these relations can affect the requirements and design of the system being designed, so the context of the system must be taken into account.
To make the "what the context diagram does not say" concrete, consider the relationship inventory for the mental health care system:
| Relationship aspect | Examples in the mental health care context |
|---|---|
| Who produces data | The prescription system produces prescription data the mental health care system may read |
| Who consumes data | The statistics system consumes anonymized treatment data for research |
| Who shares data | The patient record system shares personal patient information in both directions |
| Connectivity | Direct connection, connection through a network, or no connection (independent, transferring information as required) |
| Location | Co-located in one building or geographically distributed across clinics and hospitals |
Every row of this inventory is a requirements question in disguise. If the statistics system only receives a nightly file, that is a batch interface; if it must reflect current treatments, that is a real-time interface. The context diagram opens the conversation; the relationship inventory is what the conversation must cover.
4.3.5 Business Process Models
A simple context model is often complemented by business process models — process models that show the end-to-end flow of the various activities in the system. A business process model describes both the manual and the automated processes in which a particular software system may be used, so it extends the static snapshot of the context diagram into a picture of how work actually moves.
The context diagram answers "which systems are involved?"; the business process model answers "what actually happens, step by step, and where does the software fit into the human process?" The involuntary detention process of section 4.4 is exactly such a model: it shows the manual decision-making (assessing danger), the automated steps (recording the detention, updating registers), and the handoffs between people and systems — all things a context diagram cannot show because it has no time and no sequence. In UML, activity diagrams are the standard notation for business process models, which is why the two sections sit together: the context model names the players, and the activity diagram choreographs the play.
Recap + bridge. Context modeling begins with the system boundary — a decision about scope made early, with stakeholders, that trades off duplication against dependency and is never purely technical: it is a social and organizational judgment with political consequences. The context diagram then names the system's environment (patient record, admission, prescription, appointment, statistics, and management reporting systems for the running example), and business process models add the flow of work across those systems. The next section, 4.4, picks up exactly that flow: activity diagrams, the UML notation for processes like involuntary detention.
Real-world connection. Boundary decisions and context diagrams are where enterprise integration is born. In hospital systems, national health IT programs, and bank platforms, the context diagram is effectively the map of which legacy systems must be interfaced — and the boundary decision determines whether a new system becomes an integrated hub or an isolated island. The iLearn-style configurable boundary also appears in commercial enterprise software, which ships with configuration options that effectively let each customer draw their own system boundary at deployment time.
4.4 Activity Diagrams
Hook. In the mental health care system there is one process nobody may shortcut: deciding to detain a patient against their will. The law says the decision must be reviewed, and the patient's rights must be protected. How do you make a software system honor that requirement? You build it into the diagram — the activity diagram simply cannot reach the end of the process without passing through the review steps and the notifications. This section shows how activity diagrams encode such guarantees.
4.4.1 What Activity Diagrams Show
An activity diagram shows the activities in a process and the flow of control from one activity to another — the specific sub-processes that must be carried out and the order in which they happen. It captures the path from the input of a process to its output, including every transformation in between. In the mental health care system, the example used here is an activity diagram for one particular scenario, built for a business process called involuntary detention.
The scenario works like this. A patient affected by a mental health issue who is considered harmful to others — or to himself — may be detained in a hospital so that treatment can be administered, or even taken to the police station to be taken into custody, depending on the condition of his mental health. Detention against the patient's will is a serious step, so the decision to detain a patient must be reviewed: people cannot be held indefinitely in custody or in a hospital without sufficient reasons. One of the critical requirements of the mental health care system is to ensure that such safeguards are implemented and that the rights of the patients are respected. The activity diagram is how the system expresses that requirement: the diagram itself forces the detention process to pass through the review steps and to notify the parties that protect the patient's rights.
Why activity diagrams are requirements machines. An activity diagram is not a pretty picture of a process — it is a statement of constraints that the implemented system must honor. Every element is a requirement: the join before the notifications means "no notification may be sent before the transfer is complete"; the guards mean "the detention path must be selected on the basis of the patient's danger category"; the fork means "these notifications are independent and must not block each other." When a stakeholder approves the activity diagram, they are approving these obligations. In the involuntary detention case the diagram itself is a safeguard: the flow cannot bypass the review steps, so the software cannot either.
4.4.2 The Notation of an Activity Diagram
The notation of an activity diagram, as used in this example:
- The start of the process is indicated by a solid circle — a filled circle.
- The end is indicated by a filled circle inside another circle.
- Rectangles with rounded corners represent activities: the specific sub-processes that must be carried out.
- Systems used to support the sub-processes can be included as objects in the diagram, shown as separate systems using the UML stereotype feature, where the type of the entity in the box is shown between special symbols — for example, the admission system and the mental health care system itself appear as separate systems in the involuntary detention diagram.
- Arrows represent the flow of work from one activity to another.
- A solid bar (vertical or horizontal) indicates activity coordination. When the flow from more than one activity leads into a solid bar, all those activities must be complete before progress is possible — the bar is a join. When the flow from a solid bar leads out to a number of activities, those activities may be executed in parallel — the bar is a fork.
- Arrows may be annotated with guards, written in square brackets, which indicate under what condition a particular flow is followed.
Two notational details deserve care, because they carry the meaning of the whole diagram type:
- Join versus fork is direction, not shape. A solid bar has two behaviors that look identical and mean opposite things. Trace the arrows into the bar: many arrows in, one arrow out — a join, waiting for all inputs. One arrow in, many arrows out — a fork, enabling all outputs in parallel. Drawing the arrows the wrong way turns a synchronization point into a parallel split, and the requirement changes meaning completely.
- A stereotype names the kind of thing in a box. Writing
«system» Admissions systemtells the reader that this box is not an activity and not a class, but a separate system participating in the process. Stereotypes are the UML's mechanism for extending the notation: between chevrons (the special symbols « »), you state the type of the entity, and the diagram remains within the language's rules.
4.4.3 Worked Example: The Involuntary Detention Process
Working through the involuntary detention activity diagram: the process starts at the solid circle and first decides, on the basis of the patient's condition, which of the detention paths applies. The guards on the outgoing flows — written in square brackets — distinguish two categories of patient: those who are dangerous to society and those who are not. Dangerous patients may be transferred to a police station or to a secure hospital, where they can be kept under supervision; other patients may be admitted to a hospital. These three transfers (to the police station, to a secure hospital, or into hospital admission) are alternative flows, so exactly one of them is followed.
The flows from these activities then lead into a solid bar — the join. Only when the chosen transfer has completed can progress continue. From the bar, the flow forks out again into several activities that may all be executed concurrently: informing health care, informing the patient's relatives, uploading the register for social care, and updating the system, which includes updating the patient's record and the retention register. The point of the fork is that these notifications and updates do not depend on each other and can happen at the same time.
Read as a whole, the diagram says: choose the detention path by danger category, complete the transfer, then fan out all the safeguarding notifications and record updates in parallel. Every element — the join forcing completion of the transfer, the guards selecting the path, the fork running the notifications concurrently — corresponds to a requirement the system must honor.
Trace of the involuntary detention diagram, step by step.
● start
│
▼
( Decide detention path ) ← activity, supported by the system
│
├──[dangerous]────► ( Transfer to secure facility ) │
│ e.g. police station │ exactly one
├──[dangerous]────► ( Transfer to secure hospital ) │ path is
│ │ followed
└──[not dangerous]► ( Admit to hospital ) │
│ │
▼ │
═══════════════ JOIN (solid bar) ═══════════════◄──────┘
│ ← progress possible only after the chosen transfer completes
▼
═══════════════ FORK (solid bar) ═══════════════
│ │ │ │
▼ ▼ ▼ ▼
(Inform (Inform (Update (Upload register
health patient's system: for social
care) relatives) patient care)
record +
retention
register)
│ │ │ │
▼ ▼ ▼ ▼
○ end
- Start (solid circle) → the process enters the decision.
- Decision with guards — the flow out of the decision carries square-bracket guards:
[dangerous]and[not dangerous]. Exactly one guard is true for a given patient, so exactly one of the three transfer activities runs: transfer to a police station, transfer to a secure hospital, or admission to a hospital. These are alternative flows. - The join (solid bar) — all three transfer flows converge into the bar. Because only one flow actually ran, the join has one real input — but the notation still guarantees that no flow may proceed past the bar before the chosen transfer has completed.
- The fork (solid bar) — from the bar, four flows leave in parallel: inform health care, inform the patient's relatives, update the system (patient's record and the retention register), and upload the register for social care. None of these depends on another, so the notation allows them all to execute concurrently.
- End (solid circle inside another circle) — the process completes only after all four parallel branches finish.
The requirements this diagram encodes. (a) The detention path is selected by danger category — the system must capture that category. (b) No notification leaves before the transfer completes — the system must sequence transfer before notifications. (c) The four notifications and updates are independent — the system must not serialize them or let one failure block the others.
Sense-check. The diagram has exactly one start, one end, one decision, one join, and one fork, and every path from start to end passes through the join. This is what "the diagram forces the process through the review steps" means in structural terms — there is no path that bypasses the safeguards.
The professor's own reading of the diagram captures the whole picture in one line: choose the detention path by danger category, complete the transfer, then fan out all the safeguarding notifications and record updates in parallel.
Pitfalls when drawing and reading activity diagrams.
- Reversing join and fork. Remember the direction test: many arrows in → join (wait for all); many arrows out → fork (run all in parallel). The same symbol does both jobs, and the arrows decide which. A diagram with two fork bars on the same path — two bars that each split, with nothing joining between them — hides a synchronization the process actually needs.
- Forgetting guards on the decision. An arrow out of a decision without a square-bracket guard leaves the condition unspecified. "Which patients go to the police station?" must be answerable from the diagram.
- Claiming parallel where the domain demands order. If informing relatives must happen after the system record is updated (because the letter is generated from the record), those two activities must not sit on the same fork. The fork says "independent" — use it only for genuinely independent work.
- Reading arrows as data flow. Activity diagram arrows are flow of control — work order — not data moving. The objects in the diagram (the systems supporting sub-processes) show who performs the work, not what bytes travel where.
Recap + bridge. Activity diagrams show the flow of control through the activities of a process, using filled-circle start/end symbols, rounded rectangles for activities, stereotypes for supporting systems, arrows for work flow, solid bars for joins and forks, and square-bracket guards for conditions. The involuntary detention example showed how these elements encode real requirements — the review and notification safeguards of a legally sensitive process. Where an activity diagram shows one process in detail, the next section zooms out to who interacts with whom: use case and sequence diagrams (section 4.5).
Real-world connection. Activity diagrams (and their business-process cousins) are the standard notation for documenting processes that mix people and systems — hospital admission and discharge processes, bank loan approvals, insurance claim handling. In business process management, activity models are often the blueprint from which workflow engines are configured, so the same diagram that documents the process can drive the system that executes it. For safety-critical processes like involuntary detention, the diagram doubles as an audit artifact: regulators can verify from the model alone that the safeguards exist.
4.5 Interaction Models
Hook. A use case diagram and a sequence diagram describe the same conversation — the first as a single word ("transfer data"), the second as a full account of every line spoken ("receptionist requests → server checks authorization → data moves → confirmation arrives"). Software engineers need both: the word to structure the requirements, the account of the dialogue to check the details. This section covers the three kinds of interaction worth modeling and the two diagram types that express them.
4.5.1 Three Kinds of Interaction
All systems involve interaction of some kind, and modeling interaction matters for three different reasons depending on the kind of interaction:
- User interaction — interaction with users, involving user inputs and outputs. Modeling this is important because it helps identify user requirements.
- System-to-system or subsystem-to-subsystem interaction — interaction between the software being developed and other systems in its environment, or between subsystems. Modeling this highlights the communication problems that may arise and the coordination issues between the various systems and subsystems.
- Component interaction — interaction between the components of the software system. Modeling this helps you understand whether a proposed system structure is likely to deliver the required system performance and dependability.
Each kind of interaction is modeled for a different reason, and the reason decides what you look for in the model:
| Kind of interaction | Who interacts | What modeling it reveals |
|---|---|---|
| User interaction | Users ↔ system (inputs and outputs) | User requirements — what the users need the system to do |
| System-to-system / subsystem-to-subsystem | The software ↔ other systems, or subsystems ↔ subsystems | Communication problems and coordination issues between systems |
| Component interaction | Components of the software system | Whether the proposed structure can deliver the required performance and dependability |
Notice the escalation in stakes: user interaction shapes what the system must do, system-to-system interaction shapes whether it can work with its neighbors, and component interaction shapes whether it can be fast and reliable enough. A system whose components make too many chatty calls between servers, for example, will miss its response-time target — a problem visible in the interaction model long before the code exists.
To model these interactions you can use use case modeling complemented by sequence diagrams. The two present interactions at different levels of detail, and so they may be used together: the details of the interactions involved in a high-level use case can be documented in a set of sequence diagrams showing the various interaction scenarios in detail.
4.5.2 Use Case Diagrams
Use case modeling is a technique you will already be using in regular work: you describe use cases and then create use case models. It is commonly used in UML to describe what a user expects from a system in a given interaction. We saw use cases used for requirements elicitation in the previous lecture; use case models are also useful in the early stages of system design, where you describe the interaction between the user and the system.
Each use case represents a discrete task that involves external interaction with the system. In its simplest form, a use case is drawn as an ellipse containing a verb and a noun — the action and the thing the action is performed on. The actors are drawn as stick figures, either providing inputs to the system or receiving outputs from it. Actors may be human, or they may be other systems; the stick-figure notation, which was originally developed to represent human interaction only, is now also used to represent other external systems and even hardware.
One notational warning before we go on: formally, use case diagrams should use lines without arrows. Arrowheads indicate the direction of message flow, and in a use case, messages pass in both directions, so arrows would be misleading. In the transfer data example the arrows are used informally, purely to indicate that the medical receptionist initiates the transaction and that the data is transferred to the patient record system.
Q: Why do use case diagrams formally use lines without arrowheads — doesn't an arrow make the diagram clearer? A: An arrowhead in UML notation says "messages flow in this direction." In a use case, the actors and the system exchange messages in both directions: the medical receptionist sends a command, and the system responds with a confirmation; the patient record system receives data, and the system accepts the record. An arrow pointing one way would be a false claim about the interaction. The arrows you see in the transfer data example are an informal addition — the professor uses them only to hint that the medical receptionist initiates the transaction and that data moves to the patient record system. The formal rule stands: plain lines in use case diagrams, arrows only when you are deliberately (and informally) pointing out who initiates.
A use case diagram gives only a simple overview of an interaction scenario. For a complete description of the interaction you need to add more detail, and there is a menu of formats to choose from: a text description, a structured description in a table, a decision table for documenting the details of computations or other activities, or a sequence diagram showing the sequence of interactions. You pick the most appropriate format for the model you are building.
4.5.3 Worked Example: The Transfer Data Use Case and Its Tabular Description
The transfer data use case in the mental health care system performs the task of transferring data from the mental health system to the more general patient record system. The patient record system maintains summary data about the patient, whereas the mental health system records data about each consultation. There are two actors in this use case: the medical receptionist, who is transferring the data, and the patient record system, which receives it.
Notice the two levels of detail living side by side in this one use case: the mental health system holds consultation-level records (every visit, every prescription), while the general patient record system holds only summary data — a condensed picture of the patient (personal information, diagnosis and treatment summary). The transfer data use case bridges the two levels: it moves selected information from the fine-grained system to the coarse-grained one.
A typical standard tabular format is most useful for accompanying the use case diagram. The table for transfer data has these elements:
- Actors — the medical receptionist and the patient record system.
- Description — what the use case does: transferring consultation data from the mental health system to the patient record system.
- Data to be transferred — the patient data that moves between the systems.
- Stimulus — what initiates the scenario: a command issued by the medical receptionist.
- Response — the post-condition of the scenario: a confirmation that the patient record system has been updated.
- Remarks — more constraints, such as that the receptionist must have appropriate permissions to access patient information as well as the patient record system.
Worked example: the transfer data use case, filled in.
| Field | Content |
|---|---|
| Actors | Medical receptionist, patient records system (PRS) |
| Description | A receptionist transfers data from the mental health care system to a general patient record database maintained by a health authority. The information transferred may be updated personal information (address, phone number, etc.) or a summary of the patient's diagnosis and treatment |
| Data | Patient's personal information, treatment summary |
| Stimulus | User command issued by the medical receptionist |
| Response | Confirmation that the PRS has been updated |
| Remarks | The receptionist must have appropriate security permissions to access the patient information and the PRS |
How to read the table. The Actors row names who participates — here one human (the receptionist) and one system (the PRS), which is why the stick-figure notation may represent both. The Stimulus row names what starts the scenario — a command, not a schedule and not an automatic trigger. The Response row states the post-condition — the confirmation that the update happened — so success is precisely defined. The Remarks row carries the constraints that are easy to forget in the diagram — the permission requirement, which later becomes an authorization requirement in the sequence diagram of section 4.5.5.
Sense-check. The table covers the full transaction: who (actors), what (description and data), what starts it (stimulus), what ends it (response), and what rules apply (remarks). A use case documented this way leaves no question about the interaction that the diagram itself cannot answer.
So the simple use case diagram is complemented with a structured, tabular description of what happens in the scenario: who the actors are, what data is transferred, what stimulus triggers the transaction, what response you get at the end, and what constraints apply.
4.5.4 Composite Use Case Diagrams
A composite use case diagram can show a number of use cases together. The various roles of a user — the medical receptionist, say — map to several use cases: register patient, unregister patient, view patient information, transfer data, and contact patient. Notice the naming convention: each use case has a clear, simple verb followed by a noun — the action, then the object the action is performed on.
It is sometimes possible to include all the interactions within a system in a single composite use case diagram, but the diagram may become complex because of the number of use case scenarios and actors involved. In that case you develop several diagrams, each showing a set of related use cases — for example, a diagram with all the use cases related to the medical receptionist, separate from the ones for the manager or the health care system. The recommended practice is to take one actor and the set of use cases associated with that actor at a time, and then elaborate the activities within each use case in a tabular description.
The UML includes a number of constructs for sharing all or part of a use case between other use cases, letting you structure diagrams at multiple levels of detail. While these constructs can be helpful for designers, generally end users find them difficult to understand. The details of these constructs are not covered in this course: at best, you keep the use case diagram simple and complement it with a sequence diagram. Exam note: you will not be examined on the include/extend-style sharing constructs of use case notation.
Exam note: the UML constructs for sharing all or part of a use case between other use cases (the include/extend-style mechanisms) are not covered in this course — you will not be examined on them. The practical rule is: keep use case diagrams simple, one actor and its use cases at a time, and add detail with a tabular description or a sequence diagram instead of with sharing constructs.
4.5.5 Worked Example: The View Patient Information Sequence Diagram
A sequence diagram is primarily used in UML to model interactions between the actors and the objects in the system, and between the objects themselves. The UML has a rich syntax for sequence diagrams that allows many different kinds of interactions to be modeled, but this lecture focuses on the basic sequence diagram type — you will meet the full notation in other courses such as object-oriented programming, where you need to create such models initially.
As the name implies, the sequence diagram shows the sequence of interactions that take place during a particular use case — or an instance of a use case. Take the view patient information use case, one of the medical receptionist's use cases from section 4.5.4. Its sequence diagram looks like this.
The objects and actors involved are listed at the top of the diagram: the software objects, which include the patient information server, the mental care database, and the authorization server, plus the human entity, the medical receptionist. A dotted line is drawn vertically down from each object, and the rectangle on the dotted line indicates the lifeline of the object — the time during which that object instance is involved in the computation.
You read the sequence of interactions from top to bottom. First the medical receptionist places a request to view patient information by giving the patient ID. The patient information server then checks with the authorization server, sending it the information requested, the patient ID, and the user ID of the medical receptionist. Once the authorization comes back, one of two scenarios unfolds, shown inside a box — a choice box: only one of the constrained interactions will be executed, and the condition that selects the choice is shown in square brackets. If the authorization is okay, the patient information is returned and displayed on the user's screen; if the authorization fails, an error message is shown.
Trace of the view patient information sequence diagram, step by step.
Participants, from left to right across the top of the diagram: the medical receptionist (an actor, drawn as a stick figure), the patient information server (an object, drawn as a named rectangle), the mental care database, and the authorization server. A dotted line runs vertically down from each participant; the rectangle on each dotted line marks the participant's lifeline — the span of time in which that instance is involved in the computation. Time runs down the page.
- Request. The medical receptionist calls view patient information, supplying the patient ID. (In the full notation this is an annotated arrow from the actor to the server.)
- Authorization check. The patient information server calls the authorization server, passing the requested information, the patient ID, and the user ID of the medical receptionist.
- Decision — the choice box (
alt). The response enters a box that contains two constrained interaction alternatives, separated by a dotted line, with the selecting condition in square brackets:
[authorization OK]— the patient information is returned to the server and displayed on the user's screen.[authorization fail]— an error message ("no access") is shown instead.
Only one of the two alternatives is executed; the condition decides which.
The requirement this diagram encodes. Before any patient information is displayed, the user's identity (user ID) and the request (patient ID) must be checked against the authorization server — and the two outcomes (show information, show error) must be the only two possible results.
Sense-check. Every participant appears at the top with a lifeline; every arrow carries a named message; every branch inside the choice box is guarded by a condition in square brackets; and the diagram reads top to bottom without cycles. This is the basic sequence diagram in its complete, minimal form.
There is also a sequence diagram for the transfer data use case, but its details are not gone through here. The general guidance on level of detail: unless you are using sequence diagrams for actual code generation or for detailed documentation, you do not have to include every single interaction. If you develop system models early in the development process to support requirements engineering and high-level design, there will be many interactions that depend on design and implementation decisions that have not been made yet — so do not put too much detail into sequence diagrams at the requirements engineering stage.
Pitfalls in interaction modeling.
- Adding arrowheads to use case lines as if they were formal notation. Arrows in a use case diagram claim one-way message flow; messages actually pass both ways. If you add them, say so and keep them informal — or leave them out.
- Documenting every interaction at the requirements stage. Sequence diagrams drawn early fill up with interactions that depend on implementation decisions (how the user ID is obtained, whether a check is local or remote). The guidance is to keep requirements-stage sequence diagrams thin; full detail belongs to code generation and detailed documentation.
- Forgetting who the actors are. A use case's actors include other systems, not just humans — the patient record system is an actor in transfer data. Drawing only the human actor hides half the interaction.
- Treating use cases as a substitute for detail. A use case diagram alone cannot describe an interaction; it must be accompanied by a text, tabular, decision-table, or sequence-diagram description. The diagram names the interaction; the description specifies it.
Recap + bridge. Interaction models cover three kinds of interaction — user (reveals user requirements), system-to-system (reveals communication and coordination problems), and component (reveals performance and dependability risks). Use case diagrams name the interactions (ellipse with verb + noun, stick-figure actors, plain lines) and composite diagrams group them per actor; sequence diagrams transcribe the interactions in order, with lifelines and choice boxes. Next, section 4.6 moves from behavior between things to the things themselves: structural models and class diagrams.
Real-world connection. Interaction modeling is the everyday language of API and service design: a use case diagram is effectively the contract list of an integration ("who may call what"), and a sequence diagram is the protocol walkthrough ("what messages, in what order, with what alternatives"). When the mental health care system talks to the patient record system, the sequence of calls, the authorization check, and the two outcome branches are precisely the kind of detail that integration teams negotiate — and that later appears, almost unchanged, as the interface specification.
4.6 Structural Models: Class Diagrams
Hook. Ask two different questions about the same hospital: "what files are in the filing cabinet?" and "which people are in the building right now?" — the answers share almost nothing. Software systems have the same split. The static structure — classes, attributes, and their associations, drawn as a class diagram — is different from the dynamic organization of the system while it runs. This section builds the static picture, piece by piece: classes, associations, multiplicity, generalization, and aggregation.
4.6.1 Classes, Associations, and Static versus Dynamic Models
Structural models display the organization of the system in terms of the components that make it up and the relationships between them. Structural models may be static models, which show the planned organization of the system, or dynamic models, which show the organization of the system while it is executing — and these two are not the same thing. The organization of a system as a set of interacting threads during runtime is quite different from the static, structural representation of its components and their interconnections. This lecture focuses on class diagrams for the static structural aspect, and on state models for the dynamic behavior of the system in execution.
Q: If static and dynamic models both describe "organization," why do they disagree? A: Because they answer different questions with different facts. The static model is the planned organization of the system: the classes that exist, the associations between them, the data they own — stable, drawn on a diagram, the same before and after the system runs. The dynamic model is the runtime organization: which threads are alive, which objects exist at this moment, which components are connected right now. A web server's static class diagram shows one Request class and one DataStore class; its runtime organization may be hundreds of Request instances in concurrent threads, each holding a data store connection. Neither picture is wrong — each is the organization at a different time scale. The professor's warning is that a student who quotes the static diagram as the runtime truth is describing the building from its blueprints.
Class diagram notation is used when developing an object-oriented system model, to show the classes in the system and the associations between these classes. An object class can be thought of as a general definition of one kind of system object. An association is a link between classes indicating that some relationship exists between them — and so each class may have to have some knowledge of its associated class.
When you develop models during the early stages of the software engineering process, especially during requirements engineering, objects may represent something in the real world: a patient, a doctor, a prescription, an appointment, and so on. When you develop an implementation, by contrast, you define implementation objects to represent the data manipulated by the system. The focus here is on real-world objects, because that is the right level for requirements and the early stages of software design.
The distinction between real-world objects and implementation objects is worth making precise, because it explains what the class diagrams in this lecture are for. At the requirements level, a Patient class represents the real-world thing — a person attending a clinic — with the attributes and associations that matter to the health care process. At the implementation level, a patient may be a PatientRecord data structure, a PatientService object, and a stored row — several implementation objects that together implement the one real-world object. Mixing the two levels in one diagram produces classes that are neither good requirements nor good planning.
4.6.2 Worked Example: The Mental Health Care Class Diagram
Class diagrams in UML can be expressed at different levels of detail, and the first stage is usually to look at the world, identify the essential objects, and represent them as classes. The simplest way to write a class diagram is to put the class name in a box, and to note the existence of an association between classes by drawing a line between them.
A simple class diagram shows two classes, patient and patient record, connected by an association line. At this preliminary stage you do not have to say what the association is called or what type it is. But the diagram does carry a cardinality: one to one (1..1), which means each patient has one — and only one — patient record, and each patient record is associated with one, and only one, patient. It is a cardinality you will recognize from modeling semantic data models between various entities.
Elaborating the diagram, the objects of the class patient are also involved with a number of other classes: the medical consultant, the general practitioner who referred the patient to the mental health care system, the condition the patient has, the consultation the patient attends, the medication and treatment prescribed, and the hospital doctor who runs the consultation. Each association is described by a term, and you read them as sentences:
- Patient is diagnosed with condition.
- Patient is referred by general practitioner.
- Patient is referred to consultant.
- Patient attends the consultation.
- Consultation prescribes a medication.
- Consultation also prescribes a treatment.
- Hospital doctor runs the consultation.
Cardinality is the ability to show how many objects are involved in each association. The patient–patient record association is one to one, as above. Multiplicity extends this to a range, or to an exact number of objects. The notations: 1..1 for one to one, and 1..* (spoken as "one to many") for one to many. Applying multiplicity to the mental health care diagram:
- Many patients may be referred to a single consultant, and many patients may be referred by a single general practitioner.
- Many patients may be diagnosed with multiple conditions, and a single condition can be found in many patients — a many-to-many relationship.
- A patient may attend many consultations, and a consultation may treat a number of patients.
- A consultation may prescribe many medicines, and the same medication may be prescribed by many consultations; the same holds for treatments.
- A specific limitation appears on the hospital doctor association: up to four doctors may be associated with one consultation, written 1..4.
Worked example: building the mental health care class diagram in two steps.
Step 1 — the minimal diagram. Two classes and one association:
┌──────────────┐ ┌──────────────────┐
│ Patient │ 1..1 │ Patient record │
│ (class name) │──────────│ (class name) │
└──────────────┘ 1..1 └──────────────────┘
Read the annotation: 1..1 on both ends means cardinality one to one — each patient has exactly one patient record, and each patient record belongs to exactly one patient. At this stage the association needs no name and no type; the diagram's only claim is that the two classes are related one-to-one.
Step 2 — named associations with multiplicity. Add the other classes and name every association so it reads as a sentence:
| Association (reads as a sentence) | Classes | Multiplicity |
|---|---|---|
| Patient is diagnosed with Condition | Patient ↔ Condition | Many-to-many: a patient may have several conditions, and the same condition is found in many patients |
| Patient is referred by General practitioner | Patient ↔ General practitioner | Many patients referred by one GP (1..* at the patient end) |
| Patient is referred to Consultant | Patient ↔ Consultant | Many patients referred to one consultant (1..* at the patient end) |
| Patient attends Consultation | Patient ↔ Consultation | A patient may attend many consultations (1..*) |
| Consultation prescribes Medication | Consultation ↔ Medication | A consultation may prescribe many medicines; the same medicine may be prescribed by many consultations |
| Consultation prescribes Treatment | Consultation ↔ Treatment | Same shape as the medication association |
| Hospital doctor runs Consultation | Hospital doctor ↔ Consultation | Up to four doctors per consultation — the limitation is written 1..4 |
Why 1..4 is different. Most multiplicities here are open-ended ranges (1..* = "at least one, no upper limit"). The hospital doctor association is a specific limitation: a consultation may be run by one, two, three, or four hospital doctors — but never five. The diagram records a real-world rule of the clinic with the exact bound 1..4.
Sense-check. Every association is readable as an English sentence; every multiplicity is stated at both ends; the one-to-one cardinality of step 1 is preserved; and the special case (1..4) is captured explicitly. The diagram now carries the structural facts that the requirements conversation agreed on.
4.6.3 Class Diagrams as Semantic Data Models and ER Diagrams
At this level of detail, a class diagram looks like an ER diagram — you will be familiar with ER diagrams from database design. These class diagrams are essentially ER diagrams without the attributes: only the entities appear, with no attribute columns. Similarly, they resemble semantic data models, which are used in database design and show the data entities, their associated attributes, and the relationships between the entities.
The UML does not have an ER diagram notation of its own, and it does not have a semantic data model notation, because in UML you model data using objects and relationships. However, you can use UML to represent a semantic data model: draw a class diagram with the associations and the cardinality of each association, using simplified object classes that have no operations and no attributes, where the relations are just named associations between the object classes. So when showing associations between classes, it is best to represent the classes in the simplest possible way — without attributes or operations.
Pitfall: attributes and operations clutter the association picture. The moment you fill every class box with attributes and operations, the associations — which are the point of the structural view at this level — get buried. The UML represents a semantic data model by simplified object classes: no operations, no attributes, just named associations with cardinality. When you are showing how entities relate, draw the classes in the simplest possible way; attributes and operations belong to the more detailed view of section 4.6.4.
4.6.4 Adding Attributes and Operations
To define objects in more detail you add information about their attributes — the object's characteristics — and their operations — the object's functions. A class is then represented by a rectangle with three parts: the class name in the top section, the class attributes in the middle section, and the operations in the lower section, shown as verbs with parentheses.
Take the consultation class: consultation is essentially an activity carried out by the doctor, who consults a patient and prescribes medications and treatments. Its operations include initiate a new consultation, prescribe medication, record notes, and transcribe. You may include the types of the attributes in the middle section, but the example does not show them — data types are required only when you are doing object-oriented programming. The operations are what object-oriented programming calls methods. Three dots may be used in the attribute and operation sections to show that there are many more of each.
Two practical details from the domain: doctors may record voice notes that are transcribed, to record the details of the consultation, and to prescribe medication the doctor must use the prescribed method to generate an electronic prescription.
To make the three-part rectangle concrete, the consultation class looks like this:
┌──────────────────────────────────┐
│ Consultation │ ← class name (top section)
├──────────────────────────────────┤
│ Doctors │ ← attributes (middle section)
│ Date │ (types omitted here)
│ Time │
│ Clinic │
│ Reason │
│ Medication prescribed │
│ Treatment prescribed │
│ Voice notes │
│ Transcription │
│ ... │ ← three dots: many more attributes
├──────────────────────────────────┤
│ New() │ ← operations (lower section),
│ Prescribe() │ shown as verbs with parentheses
│ RecordNotes() │ (methods in object-oriented
│ Transcribe() │ programming)
│ ... │
└──────────────────────────────────┘
Each operation is an action the consultation supports: New() initiates a new consultation, Prescribe() prescribes medication (and, in the domain, generates an electronic prescription through the prescribed method), RecordNotes() records the consultation notes, and Transcribe() turns the recorded voice notes into a written transcription. Attribute types are optional at this modeling stage — you write them only when you are moving into object-oriented programming, where they become the declared types of the implementation.
4.6.5 Generalization
Generalization is the concept used to structure information in a hierarchical format to manage complexity. Rather than learn the detailed characteristics of everything we experience, we learn about general classes and their characteristics; we then reuse knowledge by classifying things and focusing on the difference between them and their class. For example, you may have a variety of cars, but all of them belong to the general class of car.
When modeling a system, generalization is often used to examine the classes in the system and see whether there is scope for creating generalized classes. The benefit is that common information is maintained in one place only — a good design practice, because if changes are proposed you do not have to look through all the classes in the system to see whether they are affected; you make the change at the most general level and every subclass picks it up.
The UML has a specific association to denote generalization: a triangle pointing towards the generalized class — a small arrowhead pointing up to the general class. In the mental health care example, general practitioners and hospital doctors both belong to the class of doctors and can be generalized as such. Within hospital doctor there may be a consultant and a team doctor; and a team doctor may be either a trainee doctor — a resident or intern who needs supervision — or a qualified doctor who can work unsupervised as part of the consultancy.
The rule of inheritance: the attributes and operations associated with the higher-level classes are also associated with the lower-level classes. The lower-level classes are subclasses that inherit the attributes and operations from their superclasses, and they may add more detail to the attributes or operations they derive from the parent classes.
In the doctor generalization hierarchy: all doctors — hospital doctors and general practitioners alike — have common attributes such as name, phone number, and email, and the operations register and deregister apply to every doctor in the patient health care system. Only hospital doctors also have a staff ID number, and some may be consultants with a mobile number or pager number. General practitioners do not share that information, because they work independently: they have their own independent practice and an address that is not part of the hospital. The diagram shows only part of the hierarchy — you can always extend it further.
The doctor hierarchy shows the pattern completely:
┌──────────────┐
│ Doctor │ ← superclass: Name, Phone #, Email,
└──────▲───────┘ register(), deregister()
│ (triangle/arrowhead points UP to the
│ more general class)
┌──────────────┴───────────────┐
┌───────┴────────┐ ┌─────────┴─────────┐
│ General │ │ Hospital doctor │ ← adds Staff #,
│ practitioner │ └─────────▲─────────┘ Pager #
└────────────────┘ │
┌──────────────────┴───────────┐
┌──────┴──────┐ ┌────────┴────────┐
│ Consultant │ │ Team doctor │
└─────────────┘ └────────▲────────┘
┌─────────────┴─────────────┐
┌──────┴────────┐ ┌────────┴────────┐
│ Trainee │ │ Qualified │
│ doctor │ │ doctor │
│ (supervised) │ │ (unsupervised) │
└───────────────┘ └─────────────────┘
Read the hierarchy top-down as what everyone inherits: every node below Doctor has name, phone number, and email, and supports register and deregister, because those belong to the superclass. Hospital doctor adds a staff ID number (and consultants may add a mobile or pager number), while General practitioner instead has an independent practice with its own address — hospital staff information does not apply, because GPs work independently and are not part of the hospital. Inheritance is one-way: the general class's features flow down; the subclasses only add.
4.6.6 Aggregation
Objects in the real world are often made up of different parts. For example, a study pack for a course on a learning management system (LMS) contains quizzes, assignments, lecture slides, and old question papers. In a system model you need to illustrate this whole-part relationship. For example, a patient record contains patient information and all the consultations that the patient has taken.
This association between classes is called aggregation: one object is composed of other objects. To draw it, a diamond-shaped symbol is added to the link next to the class that represents the whole — the larger thing of which the associated classes are parts. So the patient record is an aggregation of the patient and an indefinite number of consultations: the record maintains the patient's information as well as the individual record for each consultation that has been done with the doctor.
To summarize the structural modeling notation: generalization is shown by an upward-pointing triangle attached to the superclass (the base class), and aggregation is shown by a diamond attached to the class that consists of the subclasses that are parts of the main class. Together with the plain association, these give you the structural models that show the data entities in the system and their relationships.
Worked example: the study pack and the patient record, side by side.
Whole 1 — the study pack (LMS). A study pack for a course on a learning management system contains quizzes, assignments, lecture slides, and old question papers. As a UML sketch:
┌───────────────┐ ◆ (diamond on the WHOLE)
│ Study pack │◄────┐
└───────────────┘ │ ← the diamond sits next to the class that
│ represents the whole (the larger thing)
┌───────────────┼──────────────┬──────────────┐
▼ ▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌────────────┐ ┌──────────────┐
│ Quiz │ │Assignment │ │ Slides │ │Old question │
│ │ │ │ │ │ │papers │
└───────────┘ └───────────┘ └────────────┘ └──────────────┘
Whole 2 — the patient record. A patient record contains patient information and all the consultations the patient has taken:
┌────────────────┐ ◆
│ Patient record │◄────┐
└────────────────┘ │ aggregation: 1 Patient + 1..* Consultation
┌─────────────────┴──────┐
▼ ▼
┌───────────┐ ┌──────────────┐
│ Patient │ 1..* │ Consultation │
│ (1) │◄────────►│ (indefinite │
└───────────┘ │ number) │
└──────────────┘
The diamond marks the whole; the parts (quiz, assignment, slides, papers — or patient information and consultations) hang off it. The multiplicity on the consultation end is 1..* — an indefinite number of consultations — while the patient end is exactly one.
Sense-check. In both cases the whole-part relationship is directional (the record contains the consultation; the consultation does not contain the record), and that direction is exactly what the diamond records. Generalization would be wrong here: a patient record is not a kind of consultation — it contains consultations. That is the practical test: is-a → generalization triangle; has-a (part-of) → aggregation diamond.
Pitfalls in structural modeling.
- Confusing generalization with aggregation. The test is the relationship, not the diagram: "is a" (a consultant is a hospital doctor) → generalization, triangle; "has / is made of" (a patient record contains consultations) → aggregation, diamond. Drawing a diamond where a triangle belongs states the wrong fact about the domain.
- Drawing the diamond on the part instead of the whole. The diamond sits next to the class that represents the whole — the larger thing the parts belong to. On the part, the symbol claims the wrong direction.
- Leaving multiplicity unstated. The class diagram's power is the counts (
1..1,1..*,1..4). Without them, a reader cannot tell whether a patient may have two records or two hundred. - Using implementation objects at the requirements level. Real-world objects (patient, doctor, prescription) belong in requirements class diagrams; implementation objects (database records, service objects) belong to design. Mixing the two levels makes the model neither.
- Quoting the static diagram as runtime truth. The static organization (classes, associations) is not the dynamic organization (threads, live instances). The two models answer different questions (section 4.6.1).
Recap + bridge. Class diagrams show the static structure: classes as boxes, associations as lines that read as sentences, cardinality and multiplicity as counts (1..1, 1..*, and the clinic's 1..4), detail as three-part rectangles (name, attributes, operations), hierarchy as generalization (triangle toward the superclass, with inheritance of attributes and operations), and whole-part structure as aggregation (diamond on the whole). At the entity level, class diagrams double as ER diagrams and semantic data models — UML's way of representing them. Next, section 4.7 turns from the static picture to the dynamic one: behavioral models and state diagrams.
Real-world connection. Class diagrams are the backbone of object-oriented development: every object-oriented project — from hospital systems to banking platforms — starts from the classes and associations agreed in the requirements stage, and the generalization and aggregation structures carry over directly into the inheritance and composition of the implementation language. In database design, the same entity-level diagram becomes the ER model from which tables and relationships are derived. Learning management systems like the study pack example (quizzes, assignments, slides, papers as parts of a pack) show aggregation in everyday products: a course, an order, and a playlist are all aggregates of their contents.
4.7 Behavioral Models: State Diagrams
Hook. Some systems have no database and no user login — but they have a strict sense of what they are doing right now: waiting, heating, disabled because a safety interlock is open. A system that must react to events continuously cannot be described with a flow of data; it has to be described as a set of states and the events that move it between them. This is event-driven modeling, and it is the modeling language of every real-time system — from kitchen appliances to chemical plants.
4.7.1 From Data-Driven to Event-Driven Modeling
The behavioral models of a system — how the system responds when it is executing — can be approached in two ways, and it is worth noting who finds which one easier. Users of a system often find data flow diagrams more simple and intuitive, because they follow the data from input to output. Software engineers, on the other hand, may prefer sequence diagrams to model the system.
The split is not about taste; it is about what each group knows. A data flow diagram shows the sequence of processing: input data arrives, a transformation acts on it, the result moves to the next transformation, and eventually an output leaves. Nonexperts find this natural because it mirrors how work appears to flow — the same reason activity diagrams in the UML can stand in for data flow diagrams. Software engineers, however, are used to thinking in terms of objects and the calls between them, so they naturally reach for sequence diagrams, which highlight the objects and their message exchanges. Both are valid behavioral views; they just foreground different things — data flow diagrams foreground the operations, sequence diagrams foreground the objects.
Moving on from this data-driven modeling to event-driven modeling: event-driven modeling shows how a system responds to external and internal events. It is based on the assumption that a system has a finite number of states, and that events — also called stimuli — may cause a transition from one state to another. For example, a system controlling a valve in a chemical factory may move from a state called valve open to a state called valve closed when an operator command (a stimulus) is received.
This view of a system is particularly appropriate for real-time systems, where the dynamic view of the various components and which states they are in matters constantly. Event-driven modeling is used extensively while documenting or designing real-time systems.
Q: Why is a real-time system 'a finite number of states' and not just 'a program that reacts to inputs'? A: Because in a real-time system the current situation determines what each event means. Consider the chemical factory valve: when the operator sends the close command, the valve moves from valve open to valve closed — but the same command means something different in other states (in valve closed, it does nothing; in valve moving, it may mean "finish the move and hold"). The state is the system's memory: it is the fact that makes the identical event have different consequences. The valve example shows the essential mechanism in its purest form — the operator command (the stimulus) causes the transition from one state to another — and the same mechanism, scaled up, is how real-time systems are modeled and documented.
4.7.2 State Machine Concepts
UML has diagrams specifically suited to real-time systems: state diagrams, which are based on state transition diagrams and show the system states and the events that cause transitions from one state to another. They do not show the sequence of flow of data within the system — that is the job of the data flow diagram — though they may include more information about the computations carried out in each state.
State machine models — also called state models or state charts — model the behavior of the system in response to internal and external events. The system's states are shown as nodes, and the events that cause the transitions between states are shown as lines (arcs) connecting the nodes. When an event occurs, the system moves from one state to another. State diagrams, or state charts, are part of UML and are used to represent state transition diagrams or state machine models.
Three concepts carry the whole diagram type:
- State — a situation in which the system is waiting, drawn as a rounded rectangle with a name. While in a state, the system may perform an action, written after "do" (for example, a state may say "do: display time" — an action performed while the system is in that state).
- Event (stimulus) — something that happens to the system from outside (a button pressed, a door opened) or inside (a timer expiring). Events are the only things that move the system between states.
- Transition — the move from one state to another, drawn as an arc labeled with the event that causes it.
The UML state diagram is based on statecharts, a notation developed by Harel in 1987 precisely to make state-based modeling manageable for large real-time systems — which is why the superstate mechanism of section 4.7.4 is part of the notation from the start.
4.7.3 Worked Example: The Microwave Oven State Diagram
To illustrate event-driven modeling, consider a simple example: a microwave oven. Any electronic equipment is quite complex in reality, but this simplified version exists purely to make the concept of a state diagram clear. And the skill you are expected to build here is the reverse direction: for a given description, you should be able to draw a simple state diagram showing the various states and the events that cause the transitions from one state to another. Exam note: expect to draw a state diagram from a plain description of a device's operation.
The microwave oven has a switch to select either full power or half power, a numeric keypad to set the cooking time, and a start/stop button; an alphanumeric display shows whether the system is waiting or ready. The normal sequence of actions: first select the power level, either full or half; then input the cooking time using the numeric keypad; then press start. For safety reasons the oven should not operate when its door is open, and the simple display is used to show various alerts and warning messages.
In a UML state diagram, rounded rectangles represent the system states, each with a name — waiting, full power, half power, set time, enabled, disabled, operation, and back to waiting. The state name may be complemented by an action to be performed in the state, written in the form "do: display time" — an action that is performed while the system is in that state, such as displaying the time or reading the keypad input for setting the time.
Walking through the diagram from start to finish: the system starts from the waiting state — the start is drawn as a solid circle, as in activity diagrams, and the end as a solid circle inside another circle. From waiting, the system responds to either the full power or the half power button. Users can change their minds after selecting one of these: from full power they may press half power, and from half power they may press full power. Then the time is set: the system moves to the setting time state, the time is set, and if the door is closed, the system becomes ready. You can then enable the start button, and pressing start begins the oven operation: cooking takes place for the specified time. At the end of the cooking cycle the system returns to the waiting state.
You can read the diagram from left to right, from start to stop. Within each state, a certain action is performed, and from each state you transition to another by responding to an event. This example is simplified — in typical state-based modeling, the number of possible states increases quite rapidly, and for large system models you need to hide detail.
Worked example: tracing the microwave oven state diagram.
Sketch of the state diagram (states as rounded rectangles, events on the arcs, start as a filled circle):
● start
│
▼
┌──────────┐ Full power ┌──────────────┐
│ Waiting │───────────────►│ Full power │◄──────────────┐
│ do: │ │ do: set │ │
│ display │◄───────────────│ power = 600 │ │
│ time │ Half power └──────┬───────┘ │
└────┬─────┘ │ Half power │
│ Half power ▼ │
└──────────────►┌──────────────┐ Full power │
│ Half power │──────────────────────┘
│ do: set │
│ power = 300 │
└──────┬───────┘
│ Number (numeric keypad)
▼
┌──────────────┐
│ Set time │
│ do: get │ Timer
│ number │──────► (set → ready when
│ exit: set │ door closed)
└──────┬───────┘
│ Door closed
▼
┌──────────────┐ Start ┌──────────────────┐
│ Enabled │───────────►│ Operation │
│ do: display │ │ (super state — │
│ 'Ready' │ │ see 4.7.4) │
└──────────────┘ └────────┬─────────┘
▲ Door open │
│ │
└─────────────── Door closed ◄───────┘
(Door open anywhere → Disabled:
do: display 'Not ready')
Step-by-step trace.
- Start (filled circle) → the system enters Waiting ("do: display time" — the display shows the current time).
- Power selection. From Waiting, pressing the full power button moves the oven to the full power state ("do: set power = 600"), and pressing half power moves it to half power ("do: set power = 300").
- Changing the mind. Users may switch directly: from full power, pressing half power moves to half power, and from half power, pressing full power moves back to full power. The diagram shows both arcs, so the "what if I pressed the wrong button?" case is modeled.
- Setting the time. From either power state, pressing a numeric keypad key moves the oven to the set time state ("do: get number"; "exit: set time" — the time is committed when leaving). The timer event then sets the time.
- Ready to cook. If the door is closed, the system moves to the enabled state ("do: display 'Ready'").
- Operation. Pressing start begins the operation state — cooking for the specified time, after which the system returns to Waiting.
- Safety. The door open event from any operating state moves the system to the disabled state (oven operation disabled for safety; display shows "Not ready"); door closed returns it to enabled — and the cancel event returns it to Waiting.
Reading the diagram left to right, start to stop: every state has a name and an optional "do:" action; every arc is labeled with the event that triggers the transition; and every path eventually returns to Waiting. The door is both a setup condition (cooking starts only when closed) and an interrupt (opening it during operation disables the oven).
Sense-check. The trace covers every step of the professor's normal sequence — select power, set time, press start, cook, return to waiting — plus the safety behavior (door open → disabled) and the user's change-of-mind paths. If you can re-draw this diagram from the description alone, you have the skill the exam expects: given a plain description of a device, produce the states and the events that cause the transitions.
4.7.4 Super States
One way to hide detail in a large state model is the super state: a state that encapsulates a number of separate states. The super state looks like a single state at a particular level of the high-level model, but it can be expanded to show more detail on a separate diagram.
In the microwave example, the operation state is a super state that expands into a number of substates. The operation starts with a status check: if any problems are discovered — a turntable fault or a microwave emitter fault, for example — an alarm is indicated; if everything is okay, the system moves to the cooking state, where it runs the microwave generator for the specified time, and upon completion sounds a buzzer for five seconds. From within the operation super state, other events can pull the system out of it entirely: if the door is opened during the operation state, the oven goes to the disabled state; if the operation is cancelled, it goes back to the waiting state; and once the operation completes, it automatically goes to the waiting state. In this way the complexity of the state diagram can be managed: the high-level diagram stays readable, and the detail lives in the expansion.
The super state is a viewing mechanism, not a new kind of behavior. The expanded diagram shows the same events the high-level diagram showed — the door-open arc still leaves the whole super state — and the substates exist only inside it. The gain is that the high-level diagram has one box where the detailed diagram would have five, and the five live on their own diagram where they can be studied without noise. Two facts make the super state work:
- Transitions to and from the super state apply to it as a whole. "Door open → Disabled" on the super state means the door-open event exits the super state from any of its substates. The detail diagram does not have to repeat that arc on every substate.
- Entry into the super state always begins at its initial substate. Entering operation means starting with the status check — the substate marked as the initial one inside the expansion.
┌───────────────────────────────────────────────┐
│ Operation (super state) │
│ ● → Checking → [OK] → Cooking → Done │
│ │ │ │ │
│ │ faults │ ▼ │
│ ▼ │ (buzzer on │
│ Alarm │ for 5 secs.) │
│ │ │ │ │
│ ▼ │ ▼ │
│ (Disabled) │ (→ Waiting) │
│ Door open → exits super state entirely │
│ Cancel → back to Waiting │
└───────────────────────────────────────────────┘
4.7.5 Complementing State Diagrams with Tables
State models of a system provide an overview of event processing, but you normally have to extend them with a more detailed description of the stimuli, in a tabular format, together with the states and the events. The table lists the states and the events that stimulate the state transitions, along with a description of each state and event.
For the microwave oven, the various states are: waiting state, half power state, full power state, set time state, disabled state, enabled state, and operation state — and in the operation state you describe what happens during the operation. Apart from the states, you can list the events or stimuli: pressing the button for half power, pressing the button for full power, switching on the timer, entering the number of units of time with the numeric keypad, opening the door, closing the door, pressing the start button, and pressing the cancel button.
Worked example: the microwave oven states and stimuli tables.
Table A — States.
| State | Description |
|---|---|
| Waiting | The oven is waiting for input. The display shows the current time |
| Half power | The oven power is set to 300 watts. The display shows "Half power" |
| Full power | The oven power is set to 600 watts. The display shows "Full power" |
| Set time | The cooking time is set to the user's input value. The display shows the cooking time selected and is updated as the time is set |
| Disabled | Oven operation is disabled for safety. Interior oven light is on. Display shows "Not ready" |
| Enabled | Oven operation is enabled. Interior oven light is off. Display shows "Ready to cook" |
| Operation | Oven in operation. Interior oven light is on. Display shows the timer countdown. On completion of cooking, the buzzer is sounded for 5 seconds. Display shows "Cooking complete" while the buzzer is sounding |
Table B — Events (stimuli).
| Stimulus | Description |
|---|---|
| Half power | The user has pressed the half-power button |
| Full power | The user has pressed the full-power button |
| Timer | The user has pressed one of the timer buttons |
| Number | The user has pressed a numeric key |
| Door open | The oven door switch is not closed |
| Door closed | The oven door switch is closed |
| Start | The user has pressed the Start button |
| Cancel | The user has pressed the Cancel button |
How the tables and the diagram work together. The diagram gives the overview — which state leads to which, under which event. The tables give the detail — what each state actually does (the display content, the wattage, the buzzer) and what each stimulus is. A stimulus description like "the user has pressed a numeric key" defines the event precisely enough that the table and the diagram cannot drift apart in meaning.
Sense-check. Every state named in the diagram appears in Table A with its behavior; every arc label in the diagram appears in Table B with its physical meaning. The pair covers the whole behavioral model: overview in the diagram, precision in the tables.
This is behavioral modeling, and it is different from data flow modeling: data flow diagrams show the sequence of processing and the inputs and outputs, whereas the state view shows only the states and the corresponding events that trigger the transition from one state to another — including the transition that sends the system back to the waiting state from start to finish of a given scenario. Together, static and dynamic modeling — structural modeling and behavioral modeling — give you the two halves of how the system is organized and how it behaves.
Pitfalls in state modeling.
- Missing a state or an event the description implies. The description says "the oven should not operate when its door is open" — that is a disabled state plus door open and door closed events, not an optional extra. When drawing a state diagram from a description, every safety and every alternative in the text must appear as states, events, or arcs.
- Forgetting the "change of mind" paths. Users may press half power after full power. If the description allows it, the diagram needs the arc back. Omitted arcs are silently forbidden behavior.
- Putting the action on the arc instead of in the state. "do: set power = 600" belongs in the full power state; the arc is only the event "Full power". Actions describe what happens while in a state, not on the transition.
- Leaving the table out. A state diagram alone is an overview; the stimuli table (with precise descriptions of each event) is what makes the model unambiguous. The exam guidance is explicit: extend state models with a tabular description of the states and events.
- Modeling data flow with states. The state view shows states and transitions, not the flow of data — that is the data flow diagram's job. Use each diagram for its question (section 4.7.1).
Recap + bridge. Event-driven modeling assumes a finite set of states and events (stimuli) that trigger transitions, expressed in UML state diagrams: states as rounded-rectangle nodes (optionally with "do:" actions), events as labeled arcs, start and end as filled circles. The microwave oven example walked through waiting → power → set time → enabled → operation → waiting, with door and cancel interrupts; super states (like operation) hide substate detail; and state/event tables carry the precise descriptions. With this, the behavioral half of the system joins the structural half — static and dynamic modeling together describe how the system is organized and how it behaves. The next sections gather the lecture's exam guidance (section 8) and its industry applications (section 9).
Real-world connection. Event-driven modeling is the working method for real-time systems — chemical plant valve controllers, aircraft systems, phone switching systems, and the embedded controllers in domestic appliances. The microwave example scales directly: the same states-and-stimuli pattern (with super states hiding detail) is how the control software of an insulin pump, a car's engine management, or a factory robot is specified and documented, and the state/event tables become the acceptance tests the device must pass.
Exam Guidance Summary
This section collects every exam-related statement the professor made during the lecture, with pointers to the sections where each topic is developed.
- Drawing state diagrams from a description: the core practical skill of the behavioral modeling section is to take a plain-language description of a device and produce a simple state diagram showing the states and the events that cause the transitions between them. Expect this on the exam: given a paragraph describing a device's operation (like the microwave oven), you must extract the states (waiting, full power, half power, set time, enabled, disabled, operation), the events that cause the transitions (power buttons, numeric keypad, door open and closed, start, cancel), and the arcs between them — including the change-of-mind paths and the safety behavior (section 4.7.3).
- State and event tables: state models should be extended with a tabular description listing the states, the events (stimuli) that trigger transitions, and what happens in each state. A state diagram alone is an overview; the tables carry the precise meaning of each state (what the display shows, what power is set, when the buzzer sounds) and each stimulus (what pressing the key physically means), so the model is unambiguous (section 4.7.5).
- Use case notation scope: the UML constructs for sharing all or part of a use case (the include/extend-style mechanisms) are not covered in this course; keep use case diagrams simple and complement them with sequence diagrams. You will not be examined on these sharing constructs (section 4.5.4).
- Sequence diagram depth: the basic sequence diagram type is what matters here; the full rich syntax is covered in other courses such as object-oriented programming, and at the requirements stage you should not include every interaction. For the exam, know the basics: participants with lifelines at the top, interactions read top to bottom, and the choice box (alt) with square-bracket conditions (section 4.5.5).
- Modeling levels in requirements engineering: know that models are built at both the user-requirements level and the system-requirements level, and that they may be graphical, descriptive, or mathematical. The requirements document collects these models from the elicitation and analysis activity, and they are validated with the rest of the specification (section 4.1.1).
- Textbook and courseware: the topic is covered in the courseware and in the textbook chapters announced for this lecture — refer to the announced chapters and courseware modules when studying. The systems modeling chapter (context models, interaction models, structural models, behavioral models, model-driven engineering) matches the lecture's order and notation exactly.
Key Industry Applications
Every modeling technique in this lecture is used in real systems today. This section collects the named applications from the lecture, tied to the sections where each technique is developed.
- Mental health care patient information system — the running example throughout the lecture: a real system that manages information about patients attending mental health clinics and their prescribed treatments, including the legally sensitive involuntary detention process, which motivates context models, business process models, activity diagrams, use case models, sequence diagrams, and class diagrams. It is a genuine domain for the whole modeling toolkit: an organization with many interacting systems (patient record, admissions, prescriptions, appointments, statistics, management reporting), legally enforced process safeguards, and fine-grained clinical data that must be summarized for other systems (sections 4.3–4.6).
- Banking systems — an example of a case where the system boundary is relatively clear: automating customer-facing operations while backend operations stay outside the new system. When the boundary is obvious, the context model is quick to draw and the project concentrates its analysis inside the line (section 4.3.1).
- Chemical factory valve control — a canonical real-time example of event-driven modeling: a controller moves a valve from open to closed on an operator command. The valve is the purest illustration of states and stimuli, and the same pattern governs plant-wide control systems (section 4.7.1).
- Real-time systems — event-driven modeling and state diagrams are used extensively when documenting or designing systems whose dynamic state matters continuously: process control, switching systems, and embedded controllers. For these systems, the state diagram is not a documentation extra — it is the specification of the control logic (section 4.7.1).
- Microwave ovens (and electronic equipment generally) — state diagrams are used to capture the states and events of embedded device operation, from power selection to safety interlock behavior with the door. Any appliance or device with buttons, a display, and safety constraints is specified this way, and the states-and-stimuli tables double as the device's acceptance tests (sections 4.7.3–4.7.5).
- Model-driven engineering — in model-based development, complete and correct UML models are converted into skeleton code, so notation discipline (line versus arrow) becomes a code-generation contract. Where platforms change quickly or code volume is large — for example, generating platform-specific code for different car models from shared platform-independent models — MDE turns the models themselves into the production artifacts (section 4.2.4).
- Agile methods — graphical models, including informal box-and-line diagrams and incomplete UML models, are used as a means of discussion and clarification between developers and stakeholders. The whiteboard sketch is the agile project's working model: fast to draw, easy to argue about, and deliberately disposable once the understanding is shared (section 4.2.2).
- Object-oriented programming — class diagrams (classes, attributes, operations, generalization, aggregation) are the structural backbone of object-oriented development, and sequence diagrams reappear in OOP courses, where the full notation is covered. The hierarchy structures drawn here (the doctor generalization, the patient record aggregation) map directly onto inheritance and composition in the implementation language (sections 4.5.5, 4.6).
- Database design — class diagrams at the entity level double as ER diagrams and semantic data models, connecting UML to the data modeling world. A requirements-stage class diagram of patients, consultations, medications, and treatments is the starting point of the database schema that stores them (section 4.6.3).
- Learning management systems (LMS) — the study pack example (quizzes, assignments, lecture slides, old question papers) illustrates aggregation as a whole-part structure: a course pack is composed of its contents, and the aggregation diamond records that relationship in the system model (section 4.6.6).
SE Lecture 4 notes · Systems Modeling
Sections Breakdown
What system modeling is, where it fits in requirements engineering and design, models of the existing versus the new system, abstraction versus alternative representation, and the four modeling perspectives.
The three uses of graphical models - stimulating and focusing discussion, documenting a system, and model-driven engineering - and the UML diagram types covered in this lecture.
Deciding the system boundary, the mental health care system example, boundaries as judgments, context diagrams, and business process models.
Activity diagrams: what they show, the notation (start and end circles, activities, stereotypes, joins, forks, guards), and the worked involuntary detention example.
The three kinds of interaction, use case diagrams, the transfer data worked example, composite use case diagrams, and the view patient information sequence diagram.
Class diagrams: classes and associations, the mental health care worked example, ER-style entity models, attributes and operations, generalization, and aggregation.
Behavioral models: from data-driven to event-driven modeling, state machine concepts, the microwave oven worked example, super states, and state and event tables.
The examinable core of the lecture grouped by topic.
Where each concept of the lecture shows up in real systems.
Exam Revision Notes
Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.
System Modeling: What It Is and Why We Do It
Must-know: A system model is an abstraction of the system from a particular perspective: it deliberately leaves out detail so the system is easier to understand. An alternative representation (e.g., a translation) must preserve all information. Models are used during requirements engineering to derive detailed requirements, during design to describe the system to implementers, and after implementation to document structure and operation.
⚠️ Top pitfall: Treating a model as an alternative representation that must keep everything, or expecting a single diagram to answer questions from all four perspectives (external, interaction, structural, behavioral).
Self-check: Why is a slide deck an abstraction of a chapter, while a translation of the chapter into another language is an alternative representation?
Connects to: Sections 4.2, 4.3 of this lecture
How Graphical Models Are Used
Must-know: The three uses of graphical models set different bars: (1) discussion models may be incomplete and informal (the norm in agile methods); (2) documentation models may be incomplete but must be correct — inaccurate is not acceptable; (3) model-driven engineering models must be complete and correct because skeleton code is generated from them, so symbol precision (line versus arrow) becomes a compile-time contract.
⚠️ Top pitfall: Using informal discussion-style notation when the model must feed code generation: a simple connector and an arrowed line carry different meanings in UML, and a code generator faithfully produces whatever the symbols say.
Self-check: Why must a documentation model be correct even though it may be incomplete?
Connects to: Sections 4.1, 4.4, 4.5 of this lecture
Context Models
Must-know: The system boundary is decided early with stakeholders: it fixes what the system will and will not do, limits system costs and the effort to understand requirements and design. It is not an objective, value-free judgment — social, organizational, and political pressures (influence, workload, site control) shape where it is drawn. The first context analysis step is a box-and-line context diagram, and simple context models are complemented with business process models of the end-to-end flow.
⚠️ Top pitfall: Treating the boundary decision as a purely technical computation: when you draw the boundary, someone's job changes, so expect the choice to be contested — and be aware that relying on other systems avoids duplicated data but makes access slower and dependent on their availability.
Self-check: Why may a diverse user base lead you to develop a configurable system rather than fixing the system boundary explicitly?
Connects to: Sections 4.1, 4.4 of this lecture
Activity Diagrams
Must-know: Activity diagram notation: solid circle = start; filled circle inside another circle = end; rounded rectangles = activities; stereotypes in chevrons («system») = supporting systems as objects; arrows = flow of work; solid bar = activity coordination, as a join (all incoming activities complete before progress) or a fork (outgoing activities execute in parallel); square-bracket guards = conditions on flows. The involuntary detention example: guards distinguish dangerous and not-dangerous patients, three alternative transfers join before concurrent notifications fan out.
⚠️ Top pitfall: Confusing join and fork: many arrows into a solid bar mean all activities must complete (join); many arrows out mean the activities may run in parallel (fork). The arrows decide the meaning, not the shape.
Self-check: In the involuntary detention diagram, why must the three transfer flows converge on a join before the notifications can be sent?
Connects to: Sections 4.3, 4.5 of this lecture
Interaction Models
Must-know: Three kinds of interaction: user interaction (identifies user requirements), system-to-system/subsystem interaction (highlights communication problems and coordination issues), and component interaction (reveals whether the structure delivers required performance and dependability). Use case notation: ellipse with verb + noun for the use case, stick figures for actors (human or other systems), and formally lines WITHOUT arrows because messages pass both ways. Detail formats: text description, structured table (actors, description, data, stimulus, response, remarks), decision table, or sequence diagram. Sequence diagrams: participants listed at top, dotted lifelines with a rectangle marking the lifetime, read top to bottom, choice boxes (alt) with square-bracket conditions. Do not include every interaction at the requirements stage.
⚠️ Top pitfall: Using arrowheads in use case diagrams as formal notation: arrows indicate one-way message flow, but in a use case messages pass in both directions, so arrows are misleading (only used informally to indicate who initiates).
Self-check: In the view patient information sequence diagram, what do the two alternatives inside the choice box represent, and what selects between them?
Connects to: Sections 4.4, 4.6 of this lecture
Structural Models: Class Diagrams
Must-know: Structural models are static (design-time organization) or dynamic (runtime organization) — these differ. Class diagrams: classes as boxes, associations as lines readable as sentences (patient is diagnosed with condition, patient is referred by general practitioner, consultation prescribes medication, hospital doctor runs the consultation), cardinality 1..1 for one-to-one, multiplicity 1..* for one-to-many and exact bounds such as 1..4 (up to four doctors per consultation). Three-part class rectangle: name, attributes, operations (methods), with three dots for more. Generalization: triangle pointing to the generalized class, subclasses inherit attributes and operations and add detail. Aggregation: diamond next to the whole class, one object composed of others (patient record aggregates patient and an indefinite number of consultations).
⚠️ Top pitfall: Confusing generalization with aggregation: 'is a' (consultant is a hospital doctor) takes the triangle; 'has / is made of' (patient record contains consultations) takes the diamond. Also: static class organization must not be quoted as the runtime organization.
Self-check: Why is the hospital doctor association written 1..4 rather than 1..*?
Connects to: Sections 4.5, 4.7 of this lecture
Behavioral Models: State Diagrams
Must-know: Event-driven modeling: a system has a finite number of states; events (stimuli) cause transitions between states — e.g., an operator command moves a chemical factory valve from 'valve open' to 'valve closed'. UML state diagrams: states as rounded rectangles (optionally with 'do: action'), events as labeled arcs connecting states, start as solid circle and end as solid circle inside another circle. The exam expects you to DRAW a simple state diagram from a plain description of a device (microwave oven: waiting, full/half power with change-of-mind arcs, set time, enabled when the door is closed, disabled on door open, operation, return to waiting). Super states encapsulate substates to hide detail (operation expands into status check, alarm on turntable/emitter faults, cooking, buzzer for 5 seconds; door open exits to disabled, cancel returns to waiting). Extend state models with a tabular description of the states and the events (stimuli) that trigger transitions.
⚠️ Top pitfall: Omitting states or events the description implies (e.g., the door-open disabled state in the microwave), or drawing the door/cancel interrupts only from some substates instead of from the operation super state as a whole.
Self-check: In the microwave state diagram, what happens to the oven if the door is opened while it is in the operation super state?
Connects to: Sections 4.6 of this lecture
Exam Guidance Summary
Must-know: Exam scope: (1) draw a simple state diagram from a plain description of a device; (2) extend state models with tables of states and events/stimuli; (3) include/extend use case sharing constructs are NOT examined; (4) basic sequence diagram type is the examined scope, full rich syntax belongs to other courses; (5) models exist at user- and system-requirements levels and may be graphical, descriptive, or mathematical; (6) study the courseware and announced textbook chapters.
⚠️ Top pitfall: Studying the full UML sequence diagram syntax or the include/extend use case constructs, which are explicitly outside this course's exam scope.
Self-check: What is the core practical skill you are expected to demonstrate for behavioral modeling on the exam?
Connects to: Sections 4.7, 4.5, 4.1 of this lecture
Key Industry Applications
Must-know: Each modeling technique maps to a named industry application: context models and boundaries (mental health care, banking), activity diagrams (involuntary detention business process), interaction models (integration with patient record systems), class diagrams (object-oriented programming, database design via ER-style entity models, LMS study packs as aggregation), and state diagrams (real-time systems: chemical factory valves, microwave ovens, embedded devices).
⚠️ Top pitfall: Treating the diagrams as academic exercises: every diagram type in the lecture is the working notation of a real domain (health care, banking, process control, embedded devices), and the same model is used from requirements through to implementation.
Self-check: Which real-time system example shows the purest states-and-stimuli pattern, and where does it appear in the lecture?
Connects to: Sections 4.3, 4.7 of this lecture
Was this lecture useful?
BitsNotes AI Assistant
Subject Notes AssistantConfigure AI Chat
Choose how to access the chatbotSigned in as
Powered by BitsNotes — 20 messages per day. No API key needed. Want unlimited access? Use "Bring Your Own Key" mode.
Sign in to use AI Chat
Get 20 free AI messages per day to ask questions about your lecture notes. Sign in with Google or GitHub — it takes 5 seconds.
Sign In to BitsNotesSwitch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.