First exams 2027 · SL & HL

B3.1.2 · Fundamentals of OOP for a single class

Designing classes, and drawing them with UML

Before any code gets written: turning a plain description of a system into the classes, methods, and relationships it actually needs.

Core for SL & HL Typically 4–6 marks · AO2/AO3 Command term: construct

Explainer

Meridian Eats, a food delivery startup, hands you one paragraph and asks for a backend: "A customer places an order. Each order is made up of one or more items chosen from the menu. Once an order is ready, a courier delivers it to the customer and marks it as delivered." No classes, no code, just a description. Before writing a single line, that description has to become an actual design, and Unified Modelling Language (UML) is the standard way to draw it.

Df

A UML class diagram is a standard diagrammatic notation for showing a system's classes, each one's attributes and methods, and how the classes relate to one another, so the design can be planned and checked before any code is written.

!

This statement asks for two separate skills, both tested: (1) deriving which classes, attributes, and methods a system actually needs from its written requirements, and (2) representing that design correctly using UML's own notation, boxes, visibility symbols, relationship lines, and multiplicity. A good design badly drawn, or a correct-looking diagram for the wrong design, both lose marks.

The visibility symbols inside each box (+ public, − private) were introduced when B3.1.5 covered encapsulation. This page's own focus is what sits between the boxes: how classes connect to each other, and what that connection is allowed to mean.

Explainer

Three relationship types, one question each

A line between two classes in a UML diagram is never just "these are related." It always answers one specific question: if the whole is deleted, does the part still make sense on its own?

Association

Two classes are linked, but each one exists completely independently of the other.

Later in this diagram: Order and Courier. An order can exist before any courier is assigned, and a courier keeps existing long after any one delivery finishes.

Aggregation

A "whole and part" link where the part can still exist on its own, and could even belong to a different whole instead.

A separate example, not in this diagram: a Restaurant has MenuItems, but a MenuItem's recipe still means something even if that restaurant closes, and the same dish could be listed by another restaurant entirely.

Composition

A stricter "whole and part" link. The part has no independent life of its own: it is created for one particular whole, and it stops being meaningful the moment that whole is gone.

Later in this diagram: Order and OrderItem. An OrderItem only ever means "one line of this specific order." Cancel the order, and its items are meaningless without it.

Explainer

Reading multiplicity: the numbers at each end of the line

Knowing two classes are associated still leaves the most useful question unanswered: how many? A number sits at each end of every relationship line, and it is not decoration, it is part of the design.

Df

Multiplicity states how many instances of one class can take part in a relationship with a single instance of the class at the other end. It is written as a minimum and a maximum separated by two dots, and * means "no upper limit."

NotationMinimumMaximumReads as
111exactly one, never zero and never more
0..101optional: either none or a single one
1..*1no limitat least one, possibly many
0..*0no limitany number at all, including none

* on its own is a common shorthand for 0..*, and both are accepted.

!

Which end does a number describe? Read it by starting at the class on the opposite side. The number sitting next to a class tells you how many of that class go with one instance of the class across the line.

So in Customer 1 —— 0..* Order, the 0..* next to Order means one Customer can have any number of Orders, including none yet. Reading it back the other way, the 1 next to Customer means each Order belongs to exactly one Customer.

Every multiplicity choice is a real design decision that a later question can ask you to justify. Writing 1..* between Order and OrderItem, rather than 0..*, is a deliberate claim: an order with zero items is not a valid order at all.

Worked example

From requirements to classes: Meridian Eats

The same requirements paragraph from the top of the page, turned into a design one deliberate step at a time.

Constructing the design Step 1 of 4

Step 1. Read the requirements, and mark the candidate nouns and verbs. Nouns tend to become classes. Verbs tend to become methods.

A customer places an order. Each order is made up of one or more items chosen from the menu. Once an order is ready, a courier delivers it to the customer and marks it as delivered.

candidate class candidate method

Step 2. List the candidate classes, with just their attributes. No methods yet, just what data each class needs to hold.

Customer
Attribute
name
email
Order
Attribute
order_id
status
OrderItem
Attribute
name
price
quantity
Courier
Attribute
name
vehicle_type

Step 3. Add the methods. Each verb from Step 1 becomes a method on whichever class is responsible for that behaviour.

Customer
Member
name
email
+ place_order()
Order
Member
order_id
status
+ add_item()
+ calculate_total()
OrderItem
Member
name
price
quantity
Courier
Member
name
vehicle_type
+ deliver_order()

Notice OrderItem got no new methods. Not every class needs behaviour of its own, some exist purely to hold structured data.

Step 4. Identify how the classes relate, and what type each relationship is. This uses the same three types just covered above.

ClassesTypeMultiplicityMeaning
Customer – OrderAssociation1 to 0..*places
Order – OrderItemComposition1 to 1..*made up of
Order – CourierAssociation0..1 to 0..1delivered by

Worked example

The assembled diagram

Everything from the stepper above, drawn as one real UML class diagram. Click any class to see exactly how it connects.

Click a class box to highlight its relationships.

1 0..* 1 1..* 0..1 0..1
Customer
− name : string
− email : string
+ place_order()
Order
− order_id : string
− status : string
+ add_item()
+ calculate_total()
OrderItem
− name : string
− price : real
− quantity : int
Courier
− name : string
− vehicle : string
+ deliver_order()

 

Check your understanding

An OrderItem only ever means "one line of this specific order," and is deleted the moment its order is cancelled. Which relationship type should connect Order and OrderItem?

Common mistake

Markers reported this pattern for B3.1.2

RecurringCandidates frequently use aggregation and composition interchangeably, drawing whichever diamond they remember more easily rather than checking which one actually matches the existence-dependency described in the scenario.

Answer frame that scores: state whether the part can exist without the whole → name the matching relationship type → justify it using that existence rule specifically, not just "they are related."

✕

What a weak answer looks like: “Order and OrderItem are composed together because they are related.” This never states the actual rule that separates composition from aggregation, so it would score the same even if the wrong diamond were drawn.

✓

What it should say: “Order and OrderItem use composition, not aggregation, because an OrderItem cannot exist without its specific Order: deleting the Order deletes its OrderItems too. This differs from Restaurant and MenuItem, where a MenuItem can still exist even if that Restaurant closes.” Names the rule, applies it, and contrasts it against the other type.

Linking question

How this connects to the rest of the syllabus

A3

In what ways can OOP be applied to database development? (A UML class diagram and a database schema describe almost the same shape from two different angles: a class's attributes become a table's fields, an association with multiplicity becomes a foreign key relationship, and composition, where the part cannot outlive the whole, becomes a cascading delete.)

Revision questions

Past-paper style. Write an answer, then reveal the marking points and mark yourself.

Question 1 · 2 marks

[2]Distinguish between aggregation and composition, using an example of each.

Question 2 · 3 marks

[3]A requirements document says: "A gym member can book multiple classes. Each class has one instructor." Identify the candidate classes and the relationship between them.

Question 3 · 4 marks

[4]Construct a UML class diagram fragment showing Order and OrderItem, including multiplicity and the correct relationship notation.

Flashcards

Active recall for this statement’s key terms.