IB Computer Science HL · Year 2 · Lesson 11

OOP Foundations & UML Class Design

Model a real-world problem with classes and objects, then turn requirements into an explicit class design.

Paper 250 minutesB3.1.1 · B3.1.2
Targets

What you need to be able to do

2 / 9
  • evaluate OOP as a way to model real-world entities using classes, objects, inheritance, encapsulation and polymorphism;
  • explain advantages and disadvantages of OOP in different programming scenarios;
  • construct a class design from application requirements;
  • use a UML class diagram to show a class name, attributes and methods, and recognize that UML can also show relationships between classes.
B3.1.1B3.1.2
Exam habitFor “Evaluate”, give strengths and limitations and reach a context-based judgement. For “Construct”, produce the requested design rather than only describing it.
Learn + retrieve

Rapid Recall Deck

3 / 9

Attempt each card first. If a term is new, flip and study it, then answer it again without looking. Mark only secure recall as “Know it”.

B3.1.1

From a real entity to an OOP model

4 / 9
RequirementsA school library wants to track each book’s title, author, availability and borrower. A book can be borrowed only when available, and returned books become available again.

Choose the state

Which information belongs as attributes of a LibraryBook object?

Include only state owned by one book.
Give each attribute a clear name.

Suitable attributes include title, author, available and borrower. Each object stores the state of one specific book.

Choose the behaviour

Which methods should the class provide so the requirements can be enforced?

Name the action.
State what changes or what is returned.

Reasonable methods include borrow(student_name), which succeeds only if the book is available, and return_book(), which clears the borrower and restores availability.

B3.1.2 · Construct

Turn requirements into a class design

5 / 9

Read the UML

+---------------------------+
| LibraryBook               |
+---------------------------+
| title                     |
| author                    |
| available                 |
| borrower                  |
+---------------------------+
| borrow(student_name)      |
| return_book()             |
+---------------------------+

State what each compartment communicates to a programmer.

The top compartment names the class, the middle lists its attributes/state, and the bottom lists methods/behaviour.

Construct a UML design

A StudyRoom must store a room number, capacity and whether it is reserved. It must support reserve(), cancel() and can_fit(group_size). A separate Reservation class stores a student name and start time. Show an association between the two classes.

StudyRoom: class name, three attributes and three methods.
Reservation: student name and start time.
Relationship: add an association line between the two classes.
StudyRoom
----------------
room_number
capacity
reserved
----------------
reserve()
cancel()
can_fit(group_size)

StudyRoom -------- Reservation

Reservation
----------------
student_name
start_time
----------------
UML relationship check: UML can also show relationships between classes—for example, a Library class related to LibraryBook objects. Later lessons distinguish inheritance, aggregation and composition; here the key skill is recognizing that relationships can be part of the design as well as attributes and methods.
B3.1.1 · Evaluate

OOP is useful, not automatically better

6 / 9
DecisionTwo developers propose OOP for different tasks: (A) a long-lived school management system with students, courses and enrolments; (B) a five-line script that renames one local file.

Evaluate OOP for both tasks

Modelling — does the problem contain entities with state and behaviour?
Maintainability / reuse — will the code grow or be extended?
Complexity / overhead — does class structure add value?
Judgement — choose where OOP is more appropriate and justify why.

OOP is a strong fit for the school system because many related entities have persistent state and behaviour; classes can improve modularity, reuse and maintenance. For the five-line renaming script, class design may add unnecessary structure and make a simple procedural solution harder to read. The value of OOP therefore depends on problem complexity and expected growth.

Exam lens

Teacher-created Paper 2 practice

7 / 9

Paper 2 mini-set

1. A fitness app must store a workout’s name, duration and completion status and support complete() and summary(). Construct a UML class design.

2. Explain the difference between a class and an object using one example from the fitness app.

3. Evaluate one advantage and one disadvantage of using OOP for a system that will eventually contain workouts, users, coaches and subscriptions.

  1. UML should contain a suitable class name such as Workout, attributes name, duration, completed, and methods complete(), summary().
  2. A class is the blueprint; an object is one concrete workout instance with actual attribute values.
  3. A strong evaluation links a benefit such as modularity/reuse/real-world modelling and a limitation such as design complexity/overhead to the growing multi-entity system.
Exit check

Can you move from requirements to design?

8 / 9

Quick oral check

Explain aloud: why is “a class is an object” an incorrect statement?

A class defines the structure and behaviour. An object is one instance created from that class.

Design repair

A student puts borrower and borrow() outside the LibraryBook class even though both directly control a book’s state. Explain one reason to move them into the class.

Keeping related state and behaviour together improves cohesion and makes the rules controlling a book easier to maintain and reuse.

Homework

Finish the learning cycle

9 / 9

IA — main task

Continue Criterion D development. Add one short note explaining a class/design decision if OOP is relevant to your solution; do not force OOP if it is not appropriate.

Paper 2 — short practice

Redo the UML construction and OOP evaluation without revealing the model. Review only flashcards marked “Review again”.