SevyDevy

Design pizza ordering with the decorator pattern

PremiumLow-level designEasy

  • Decorator pattern
  • Builder pattern
  • Factory pattern

Quick answer

This low-level design interview question asks you to design pizza ordering with the decorator pattern. Aim for a design that is modelled as clear classes, interfaces and relationships that can handle new requirements without a rewrite. Interviewers want to see how you name responsibilities, keep classes small and reason about change.

The problem

Pizza ordering with the decorator pattern is a classic OOP design question: model a pizza shop where each topping wraps the pizza and adds to its price and description. The hard part is deciding where decorators fit and where a builder or plain fields work better, while keeping money exact.

A customer picks a base pizza (margherita, farmhouse, pepperoni), a size, a crust and any combination of extra toppings. Each choice changes the price and the description on the receipt. An order holds several pizzas plus sides and drinks, applies a coupon and computes the total.

The interviewer asks you to use the decorator pattern for toppings and to explain where it fits and where it does not.

What must the system do?

  • Toppings: Any number of extra toppings, each with a price (olives 30, jalapenos 30, extra cheese 50, paneer 60, chicken 80). A topping can be added twice (double olives).
  • Description: Each pizza produces a readable description, for example "Large farmhouse, cheese-burst crust, extra cheese, double olives".
5 more requirementsUnlock to see all

How well must it do it?

  • Correct money: Prices are integers in the smallest unit; the multiplier is applied to the base and crust before toppings, and the result is rounded once.
  • Readable composition: Building a pizza in code should read like the order, not like a chain of nested constructors.
2 more requirementsUnlock to see all

What scale should you design for?

Use these numbers in your estimates.

The scale numbers unlock with this questionUnlock

Key concepts

  • Decorator pattern
  • Builder pattern
  • Factory pattern
  • Open closed principle
  • Pricing rules
  • Object oriented design

How you’ll practise

6 short steps · save and come back any time
  1. Requirements
  2. Core objects
  3. Class relationships
  4. Key flows
  5. Extensibility
  6. Wrap-up

Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.

What do interviewers look for?

In any low-level design round.

  • Lists the use cases before writing classes
  • Gives each class one clear responsibility
  • Uses interfaces where behaviour is likely to change
  • Applies a design pattern only when it solves a real problem
  • Handles edge cases and invalid states explicitly
  • Walks through one use case end to end with the model

Questions people ask about this interview question

Which design type is this question?
It is a low-level design question. You design pizza ordering with the decorator pattern and explain your choices the way you would in an interview.
Is this question asked at entry level?
It is marked Easy, so it suits engineers who are new to low-level design interviews. It is also a good warm-up before harder questions.
What should I cover first?
Start with the use cases and the core entities, then the responsibilities of each one. Agree on scope with the interviewer before you design anything.
Can I practise it for free?
It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.

Related questions

Updated · Written by the SevyDevy team

Premium questionSign up free, then unlock it