📗 Paper 4 · 4.2 Further OOP
4.2.1 UML & Class Design
Cambridge 9618 · International A Level Computer Science · ~16 min read
Notes
Video
Slides
Quiz
Worksheet

UML Class Diagrams

Unified Modelling Language (UML) is a standardised visual language for designing and documenting object-oriented systems. The most commonly used diagram in 9618 is the UML class diagram, which shows classes, their attributes, methods, and the relationships between them.

A UML class diagram has three sections:

BankAccount
accountNumber : String
balance : Real
# owner : String
+ NEW(num:String, bal:Real)
+ getBalance() : Real
+ deposit(amt:Real) : Boolean
validate(amt:Real) : Boolean
Section 1: Class name (bold, centred, purple header)
Section 2: Attributes — name : type
Section 3: Methods — name(params) : returnType

Access symbols:
+ = PUBLIC
= PRIVATE
# = PROTECTED

UML attribute and method notation

Each attribute is written as: access_modifier name : type

Each method is written as: access_modifier name(param:type, ...) : return_type

If a method returns nothing, the return type is omitted or written as : void.

UML Relationships

UML shows how classes relate to each other using different line types and arrow styles. The four key relationships for 9618 are:

—————
Association
A general "uses" relationship between classes. One class uses or references another. Shown as a plain line. Example: Teacher ——— Course (a teacher teaches courses). No ownership implied.
◇—————
Aggregation
A HAS-A relationship with a weak link — the "part" can exist independently of the "whole". Hollow diamond on the "whole" side. Example: School ◇——— Teacher (teacher can exist without school).
◆—————
Composition
A strong HAS-A relationship — the "part" cannot exist without the "whole". Filled (solid) diamond on the "whole" side. Example: House ◆——— Room (a room cannot exist without a house).
—————▷
Inheritance
An IS-A relationship. Open (hollow) arrowhead pointing TO the superclass. Example: Circle ——▷ Shape means Circle inherits from Shape. Multiple subclasses can point to one superclass.

Multiplicity (Cardinality)

Multiplicity labels on relationship lines show how many objects of each class participate in the relationship:

NotationMeaningExample
1Exactly oneAn order is placed by exactly 1 customer
0..1Zero or one (optional)An employee may have 0 or 1 manager
* or 0..*Zero or more (many)A customer can place many orders
1..*One or more (at least one)A school has at least 1 teacher
m..nBetween m and nA team has 5..11 players

Multiplicity is placed at both ends of a relationship line. Example: Customer (1) ——— (*) Order means one customer places zero or more orders.

Designing Classes from a Specification

When designing a system from a written specification, follow these steps:

  • Identify classes: nouns in the specification → candidate classes (Customer, Product, Order)
  • Identify attributes: properties/characteristics of each class (name, price, date)
  • Identify methods: verbs/actions → methods (placeOrder(), calculateTotal(), sendEmail())
  • Identify relationships: how classes interact — IS-A or HAS-A?
  • Apply access modifiers: attributes typically PRIVATE; getters/setters PUBLIC

Example: Library system specification

"A library holds many books. Each book has a title and ISBN. A member can borrow up to 5 books. The system tracks when each loan was made."

Library
name : String
+ getBooks() : List
+ addBook(b:Book) : void
Book
title : String
isbn : String
+ getTitle() : String
+ getISBN() : String
Member
memberId : Integer
name : String
+ borrowBook(b:Book) : Boolean
+ returnBook(b:Book) : void
Loan
loanDate : Date
dueDate : Date
+ isOverdue() : Boolean

Relationships: Library ◆——(1..*)—— Book (composition; books belong to library). Member (1) ——— (*) Loan (association). Book (1) ——— (*) Loan (association).

CRC Cards

A CRC card (Class–Responsibility–Collaborator) is a design tool used before drawing UML. Each card represents one class and lists what it does and who it works with.

Member
Responsibilities
Store member details (name, ID)
Track borrowed books (up to 5)
Borrow and return books
Check if overdue fines owed
Collaborators
Book
Loan
Library
FinanceSystem
Cambridge 9618 exam tip: UML questions typically ask you to: (1) draw or complete a class diagram given a specification, (2) add attributes/methods with correct notation (+/−/#), (3) add relationships with correct line types and multiplicity labels, (4) distinguish aggregation (hollow diamond) from composition (filled diamond). Know that the open arrowhead for inheritance points FROM the subclass TO the superclass. The diamond for aggregation/composition is on the "whole" (owner) side. Common exam task: "Extend the UML diagram to add a Loan class with a relationship to Member showing one member can have many loans."
⚠️ Common Mistakes
  • Pointing the inheritance arrow the wrong way — the open arrowhead points TO the superclass (parent). Think: "Circle inherits FROM Shape" — arrow goes FROM Circle TO Shape.
  • Confusing aggregation and composition — aggregation (hollow ◇): parts exist independently; composition (filled ◆): parts cannot exist without the whole. Room cannot exist without a House → composition. Teacher can exist without a School → aggregation.
  • Putting multiplicity labels on the wrong end — multiplicity goes at the END of the line closest to the class it describes. Customer (1)—(*)Order means 1 customer has * orders.
  • Forgetting access modifiers on methods — getter and setter methods should be PUBLIC (+). Private helper methods use −. Missing the symbol loses marks.
  • Using void return type for constructors — constructors typically have no return type in UML. Do not write : void after the constructor name.
  • Listing method parameters without types — in Cambridge UML notation, parameters should include their types: deposit(amount : Real) not just deposit(amount).
✅ Notes completed!
Video coming soon
Click slide or press arrow keys to navigate

Worksheet — 4.2.1 UML & Class Design

8 questions · Cambridge 9618 standard

Q1State what UML stands for and describe the three sections of a UML class diagram.[4]
✅ Mark scheme
UML stands for Unified Modelling Language [1]; the three sections of a class diagram are: (1) class name — displayed in bold at the top, usually in a coloured header [1]; (2) attributes section — lists all attributes with their access modifier (+/−/#) and data type [1]; (3) methods section — lists all methods with access modifier, parameters and return type [1].
Q2Explain the difference between aggregation and composition in UML. Give one example of each.[4]
✅ Mark scheme
Aggregation: a weak HAS-A relationship where the "part" can exist independently of the "whole" [1]; shown with a hollow/open diamond (◇) on the "whole" side; example: School ◇——— Teacher — a teacher can exist without a school [1]; Composition: a strong HAS-A relationship where the "part" cannot exist without the "whole" [1]; shown with a filled/solid diamond (◆) on the "whole" side; example: House ◆——— Room — a room cannot meaningfully exist without a house [1].
Q3Interpret the multiplicity notation: Customer (1) ——— (0..*) Order[2]
✅ Mark scheme
The (1) on the Customer side means exactly one Customer is associated with each relationship [1]; the (0..*) on the Order side means a Customer can have zero or more Orders — a customer may exist without placing any orders, but can also place many [1].
Q4A system has a Car class and an Engine class. A car has exactly one engine; the engine is custom-built and cannot exist apart from the car. Draw/describe the UML relationship between them including the correct line type and multiplicity.[3]
✅ Mark scheme
This is a composition relationship — the engine cannot exist without the car [1]; the UML shows a filled/solid diamond (◆) at the Car end of the line [1]; multiplicity: Car (1) ◆——— (1) Engine — exactly one Car has exactly one Engine [1]. Accept: Car ◆—(1)—(1)— Engine with filled diamond correctly placed at Car side.
Q5Given the specification: "A school has many students. Each student belongs to exactly one class group. A teacher can teach multiple class groups." Identify three classes and describe two relationships including multiplicity.[5]
✅ Mark scheme
Three classes: Student, ClassGroup, Teacher [1]; Relationship 1: School ◆——— Student (composition): a school has many students — School (1) to Student (*) — a student cannot exist without a school [1][1]; Relationship 2: ClassGroup (1) ——— (*) Student (association/aggregation): each student belongs to exactly 1 class group; a class group has * students [1]; Teacher (*) ——— (*) ClassGroup (association): a teacher teaches multiple class groups; a class group is taught by at least one teacher [1]. Award marks for correct class names, relationship type, and multiplicity labels.
Q6Write out a UML class diagram (in text notation) for a Product class in an online shop. Include at least 3 attributes, 4 methods (including getters), and appropriate access modifiers.[4]
✅ Mark scheme
Class name: Product [1]; Attributes (min 3, each with − modifier and type): − productId : Integer; − name : String; − price : Real; − stockLevel : Integer [1]; Methods: + NEW(id:Integer, n:String, p:Real) [no return type]; + getName() : String; + getPrice() : Real; + setPrice(p:Real) : void; + isInStock() : Boolean [1 for ≥4 methods with correct notation]; access modifiers correct throughout (+/− as appropriate) [1].
Q7Draw a UML class diagram for a Library system with three classes: Book (attributes: ISBN:STRING, title:STRING, isAvailable:BOOLEAN; method: Checkout()), Member (memberID:STRING, name:STRING), and Loan (loanDate:STRING, dueDate:STRING). Show the associations between classes with correct multiplicity notation and label each association.[5]
✅ Mark scheme
Three boxes: Book, Member, Loan with correct class names [1]; Book box shows −ISBN:STRING, −title:STRING, −isAvailable:BOOLEAN, +Checkout() [1]; Loan connects to Book with multiplicity: 1..* Loan to 1 Book (each loan involves exactly one book; a book can have many loans) [1]; Loan connects to Member: 1..* Loan to 1 Member (a member can have many loans; each loan belongs to one member) [1]; Association arrows labelled (e.g. "borrows", "involves") [1]. Award marks for correct concept even if diagram format is imperfect.
Q8State THREE differences between functional requirements and non-functional requirements. For a school management system, give one example of each type of requirement.[5]
✅ Mark scheme
Functional describes WHAT the system must DO; non-functional describes HOW WELL it must perform [1]; Functional requirements specify specific behaviours/features; non-functional specify quality attributes (performance, security, reliability, usability) [1]; Functional requirements are directly testable by running the feature; non-functional are measured against benchmarks (response time, uptime percentage) [1]; Functional example: "the system must allow a teacher to view all students in their class" [1]; Non-functional example: "the system must respond to any query in under 2 seconds for up to 500 concurrent users" [1].
Topic Quiz
Question 1 of 10
You scored
out of 10
Card 1 of 8
Click to reveal definition
🎉
All cards reviewed!
TermDefinition
🎯

Mini Test — 4.2.1 UML & Class Design

10 questions · 10 marks · 10 minutes

← 4.1.3 OOP Inheritance
68 of 82 · Cambridge 9618
4.2.2 Design Patterns →