← IB Computer Science

Design patterns in OOP

Higher Level (AHL) topic B3.2.5. A design pattern is a proven, reusable solution to a common design problem. This unit explains what a design pattern is, the three families they fall into, and the three patterns the course requires you to explain: singleton, factory and observer, and the problem each one solves.

Slide 1 / 4

What is a design pattern?

A reusable blueprint, not finished code A proven solution to a recurring problem — a guideline you adapt, not code you copy. Language-independent. Described by: intent · motivation · structure (UML) · a code example. Three families of pattern Creational how objects are created singleton, factory Structural relationships between objects Behavioural how objects communicate observer
  • A design pattern is a reusable blueprint of a proven solution to a recurring programming problem; it is a guideline, not actual code.
  • Patterns are not tied to one language, so they describe how to design a solution rather than giving you the finished code.
  • Each pattern is usually described by its intent, motivation, structure (a UML diagram) and a code example.
  • Patterns fall into three groups: creational (how objects are created), structural (relationships between objects) and behavioural (how objects communicate).

Check you've got it

0/4

1. What is a design pattern in object-oriented programming?

2. Which feature is essential to the singleton design pattern?

3. A program needs a common interface for its objects but wants each subclass to decide which specific object is created. Which pattern fits best?

4. Which pattern uses a publisher and a list of subscribers to keep objects informed of updates?

Free revision content. Multiple-choice answers are marked instantly. Written answers are marked by AI on /free-mark.