1. Introduction
| Functional models | Structural models |
|---|---|
| Represent system behavior | Represent system objects and their relationships — people, places, things |
Definition (Structural model)
- Defines the key elements (things, ideas, concepts) of the problem domain and the relationships among them.
- Creates a common vocabulary between analysts and users.
- Main goal: identify the key data in the problem domain and build a model of the key objects and their relationships.
Drawn iteratively:
- Initial drawing — business-focused, conceptual view.
- Refinement — technology-focused view (databases, files).
- Progressive detail — more detail each iteration.
2. Classes, Attributes, Operations & Relationships
2.1 Basic Concepts
| Concept | Definition |
|---|---|
| Class | Template for instances of people, places or things |
| Attribute | Property describing the state of an instance (object) |
| Operation | Action or function a class can perform |
classDiagram class Box { -volume -material +fill() +empty() }
2.2 The Four Main Relationships
| Relationship | Meaning | Example |
|---|---|---|
| Association | General connection | Student enrolls in Course |
| Generalization (inheritance) | “is-a” / “a-kind-of” — inherits attributes and operations | Car is a Vehicle |
| Aggregation (shared) | Weak “has-a” / “a-part-of” — part can exist without the whole | Department has Professors (they can move departments) |
| Composition (composite) | Strong “has-a” — part cannot exist without the whole | House contains Rooms (destroy the house → rooms cease to exist) |
3. Object Identification
Goal: identify the main objects (classes) of the problem domain.
3.1 Techniques
- Textual analysis (primary) — analyze the use cases:
- Nouns → classes
- Verbs → operations
- Start with a rough list of candidate objects.
- Brainstorming (supporting) — team suggests extra ideas to find missing/unclear objects → initial class list → then define attributes, operations and relationships.
3.2 Common Object Types
| Type | Examples |
|---|---|
| Physical things | Car, Computer |
| Incidents (events) | Order, Appointment |
| Roles | Customer, Doctor |
| Interactions | Payment, Booking |
Patterns: reusable templates made of groups of collaborating classes; solve common problems and give a starting point for similar systems.
3.3 Textual Analysis Guidelines
| Part of speech | Implies |
|---|---|
| Common / improper noun | A class |
| Proper noun / direct reference | An instance of a class |
| Collective noun | A class made of groups of instances of another class |
| Adjective | An attribute |
| Doing verb | An operation |
| Being verb (“is a”) | Classification (generalization) relationship |
| Having verb (“has”) | Aggregation or association |
| Transitive verb | An operation |
| Intransitive verb | An exception |
| Predicate / descriptive verb phrase | An operation |
| Adverb | An attribute of a relationship or operation |
3.4 Worked Example — Make Old Patient Appt
Step 1: “The Patient contacts the office regarding an appointment.”
- Classes: Patient, Office, Appointment
- Operation:
contactOffice() - Associations: Patient — Office, Patient — Appointment, Office — Appointment
Step 2: “The Patient provides the Receptionist with his or her name and address.”
- Classes: Patient, Receptionist
- Attributes: name, address
- Operation:
provideInformation() - Association: Patient — Receptionist
classDiagram class Patient { -name -address +contactOffice() +provideInformation() } class Office class Appointment class Receptionist Patient -- Office Patient -- Appointment Office -- Appointment Patient -- Receptionist
⚠ “Patient John Doe” — a proper noun is an instance (object diagram material), not a new class.
4. CRC Cards (Class–Responsibility–Collaboration)
Definition
Simple cards (one per class) used to build the structural model.
| Part | Content | Example |
|---|---|---|
| Class | The object modeled | Patient, Appointment |
| Responsibilities — Knowing | What the class knows → attributes | Patient knows name, address |
| Responsibilities — Doing | What the class does → operations | Patient books appointment |
| Collaboration | Classes it works with to complete a task | Patient (requestor) asks for appointment; Receptionist (responder) schedules it |
4.1 Example Card — Old Patient
Front side
| Class Name: Old Patient | ID: 3 | Type: Concrete, Domain |
|---|---|---|
| Description: An individual who needs to receive or has received medical attention | Associated Use Cases: 2 | |
| Responsibilities | Collaborators | |
| Make appointment | Appointment | |
| Calculate last visit | ||
| Change status | ||
| Provide medical history | Medical History |
Back side
| Attributes | |
|---|---|
| Amount (double) | Insurance carrier (text) |
| Relationships | |
| Generalization (a-kind-of) | Person |
| Aggregation (has-parts) | Medical History |
| Other associations | Appointment |
Translated to a class diagram:
classDiagram Person <|-- OldPatient OldPatient o-- MedicalHistory : has-parts OldPatient -- Appointment class OldPatient { -amount : double -insuranceCarrier : text +makeAppointment() +calculateLastVisit() +changeStatus() +provideMedicalHistory() }
4.2 CRC Cards & Role-Playing
After creating the cards, role-play use-case scenarios: team members take the roles of actors and objects and act out each step (using the activity diagrams). This discovers missing objects, attributes, operations, relationships and tests whether the model is clear and complete.
- Choose the most important use case.
- Assign roles (actors and classes).
- Perform each step of the scenario.
- Discover and fix problems until it concludes successfully.
- Repeat for the remaining use cases.
5. Class Diagrams
Definition
A static model showing classes and their relationships.
- Classes — objects in the system; contain attributes (name, address) and operations (
createAppointment()). - Relationships — lines between classes, with multiplicity (e.g., one Patient → many Appointments).
Example — appointment system (simplified from the slide’s sample class diagram):
classDiagram Participant <|-- Employee Participant <|-- Patient Employee <|-- Doctor Employee <|-- Receptionist Employee <|-- Nurse Patient "1" -- "0..*" Appointment : schedules Appointment "0..*" -- "1" Doctor : assignedTo Patient "0..*" -- "1..*" Symptom : suffers Patient "1" *-- "1" MedicalHistory : provides class Participant { -lastname -firstname -address -phone -birthdate -/age } class Patient { -amount -insuranceCarrier +makeAppointment() +calculateLastVisit() +changeStatus() +provideMedicalHistory() } class Appointment { -time -date -reason +cancelWithoutNotice() } class MedicalHistory { -heartDisease -highBloodPressure -diabetes -allergies }
5.1 Types of Classes
| Type | Rule | Notation |
|---|---|---|
| Abstract | Cannot be instantiated; used as a base class | Name in italics |
| Root | Cannot have a parent; top of hierarchy | <<root>> |
| Leaf | Cannot have children; bottom of hierarchy | <<leaf>> |
5.2 Attributes
- Properties describing an object’s state (Participant → firstName, lastName, address).
- Derived attribute: computed from others, shown with a slash:
/age(derived from birthdate).
5.3 Operations
Written with parentheses that may hold parameters.
| Type | Effect on state |
|---|---|
| Constructor | Creates and initializes an object |
| Query | Retrieves information — does not change state |
| Update | Modifies attributes — changes state |
| Destructor | Deletes/removes an object |
⚠ Common operations available to every class (create/delete instance, getters/setters) are not shown. Only operations unique to the class appear.
5.4 Visibility
Controls who can access an attribute/operation (protects data, ensures consistency). UML has no default visibility — it must be specified.
| Symbol | Visibility | Accessible from |
|---|---|---|
+ | Public | All classes |
− | Private | Same class only |
# | Protected | Same class and subclasses |
~ | Package | Classes in the same package |
5.5 Scope
| Scope | Meaning | Notation | Example |
|---|---|---|---|
| Instance (default) | Each object has its own copy; invocation may affect the instance’s state | normal | Each Applicant has its own name |
| Class (static) | One shared value for all objects; invocation doesn’t affect the classifier’s state | underlined | origin : Point = (0,0) shared by all points |
5.6 Multiplicity of Attributes
How many values an attribute can hold for one object:
address [2]→ exactly 2 addressesaddress [0..*]→ zero or many
Worked example — putting §5.2–5.6 together:
classDiagram class Applicant { -name : String -address [0..*] : String -birthdate : Date -/age : int +count$ : int +Applicant(name) +getAge() int +changeAddress(newAddr) }
-name→ private, instance scope.address [0..*]→ attribute multiplicity./age→ derived frombirthdate.count$→ class (static) scope — rendered underlined in UML.Applicant(name)constructor ·getAge()query ·changeAddress()update.
6. Relationships in Class Diagrams
- A line between classes, named (e.g.,
IsLocatedIn). - A class can relate to itself (Employee manages Employee).
- Can be directional — a small triangle shows reading direction (“Spare Tire is located in Trunk”, not the opposite).
- Multiplicity = number of instances of one class associated with one instance of the other.
Example — sample associations
classDiagram Invoice "0..*" -- "1" PurchaseOrder : AssociatedWith Pilot "0..*" -- "0..*" Aircraft : Flies ▸ SpareTire "0..1" -- "0..1" Trunk : IsLocatedIn ▸
6.1 Multiplicities
| Meaning | Notation | Example |
|---|---|---|
| Exactly one | 1 | A Department has one and only one Boss |
| Zero or more | 0..* | An Employee has zero to many Children |
| One or more | 1..* | A Boss is responsible for one or more Employees |
| Zero or one | 0..1 | An Employee can be married to zero or one Spouse |
| Specified range | 2..4 | An Employee takes two to four Vacations per year |
| Multiple, disjoint ranges | 1..3,5 | An Employee is a member of one to three or five Committees |
Reading rule: the multiplicity is written next to the class it counts. In Department "1" -- "1" Boss, the 1 beside Boss says each department has exactly one boss.
⚠ Read each end separately:
Patient "1" -- "0..*" Appointmentmeans one patient has 0..* appointments and each appointment belongs to exactly 1 patient.
6.2 Generalization, Aggregation, Composition
| Generalization | Aggregation | Composition | |
|---|---|---|---|
| Meaning | Subclass inherits from superclass | Weak logical “part-of” | Strong physical “part-of” |
| Part independent? | — | Yes | No |
| Notation | Hollow triangle at the superclass | Hollow diamond ◇ at the whole | Filled diamond ◆ at the whole |
| Example | Car → Vehicle | Team has Players | House has Rooms |
Generalization hierarchy:
classDiagram Vehicle <|-- Land Vehicle <|-- Air Vehicle <|-- Sea Land <|-- Truck Land <|-- Car Air <|-- Plane Air <|-- Helicopter Sea <|-- Ship Sea <|-- Submarine
Aggregation (◇) vs. composition (◆):
classDiagram Department "1..*" o-- "1..*" Employee : IsPartOf Vehicle "1" o-- "1..*" Wheel : IsPartOf Office "1" o-- "0..*" Desk : IsPartOf Car "1" *-- "1..*" Door : IsPartOf Building "1" *-- "1..*" Room : IsPartOf Mouse "1" *-- "1..*" Button : IsPartOf
⚠ The diamond goes on the whole, never on the part. Test: “if the whole is destroyed, does the part disappear?” Yes → composition; No → aggregation.
6.3 Roles in Relationships
A role describes what a class does in a relationship; written near the class at the end of the association line.
classDiagram Citizen "0..* owner" -- "1..* ownedBy" Car
Citizens play the role owner; Cars play the role ownedBy.
7. Object Diagrams
Definition
Like a class diagram but with real instances and actual attribute values.
- Class:
Doctor→ Object:Dr. Smith : Doctor. - Used to discover missing attributes, relationships or operations, or misplaced ones.
Worked example — instances of the appointment class diagram:
flowchart LR JD["<u>John Doe : Patient</u><br/>lastname = Doe<br/>firstname = John<br/>address = 1000 Main St<br/>phone = 555-555-5555<br/>birthdate = 01/01/72<br/>/age = 40<br/>amount = 0.00<br/>insurance carrier = JD Health Ins"] A1["<u>Appt1 : Appointment</u><br/>time = 3:00<br/>date = 7/7/2012<br/>reason = Pain in Neck"] DS["<u>Dr. Smith : Doctor</u><br/>lastname = Smith<br/>firstname = Jane<br/>address = Doctor's Clinic<br/>phone = 999-999-9999<br/>birthdate = 12/12/64<br/>/age = 48"] S1["<u>Symptom1 : Symptom</u><br/>name = Muscle Pain"] JD --- A1 A1 --- DS JD --- S1
Issues found by reviewing the instances
| Issue | Fix |
|---|---|
1. Appointment has a reason attribute (“Pain in Neck”) | Model Reason as a class associated with both Symptom and Appointment |
2. Symptom is associated with Patient | A symptom (e.g., “muscle pain”) occurs across many patients → link Symptom to the Appointment (or its reason), not to one patient |
Updated class diagram: Patients have Appointments; each Appointment can involve multiple Symptoms.
classDiagram Patient "1" -- "0..*" Appointment : schedules Appointment "0..*" -- "1..*" Symptom : involves Appointment "0..*" -- "1" Doctor : assignedTo
8. Steps to Create Structural Models
flowchart LR A[1. Create CRC cards] --> B[2. Review cards<br/>find missing items] B --> C[3. Role-play<br/>fix breakdowns] C --> D[4. Create class diagram] D --> E[5. Review diagram<br/>remove unnecessary items] E --> F[6. Review & validate] C -.->|new cards| A
- Create CRC cards.
- Review them — identify missing objects, attributes, operations, relationships.
- Role-play the cards — look for breakdowns, correct, create new cards.
- Create the class diagram.
- Review it — remove unnecessary classes, attributes, operations, relationships.
- Review and validate the model.
9. Verifying & Validating the Structural Model
The analyst walks through the model with developers and users, explaining the reasoning behind each class.
| # | Rule (CRC card → class diagram) |
|---|---|
| 1 | Each CRC card ⇒ a class in the diagram |
| 2 | Responsibilities (front) ⇒ operations |
| 3 | Collaborators (front) ⇒ imply the relationships listed on the back |
| 4 | Attributes (back) ⇒ attributes in the diagram |
| 5 | Each attribute on the back has a data type (e.g., name is a string) |
| 6 | Relationships (back) correctly drawn — aggregation/association type and multiplicity |
Worked example — checking the Old Patient card (§4.1) against its class (§4.1 diagram):
- Card → class
OldPatient✓ (rule 1) - 4 responsibilities → 4 operations ✓ (rule 2)
- Collaborators Appointment, Medical History → association + aggregation on the diagram ✓ (rules 3, 6)
amount : double,insuranceCarrier : text→ typed attributes ✓ (rules 4, 5)- Generalization to
Persondrawn with hollow triangle ✓ (rule 6)