Skip to content
Preptima
mediumDesignCodingMidSeniorStaff

A bundle can contain products or other bundles, and the pricing code should not care which it is holding. How would you model that?

6 min readUpdated 2026-08-15Target archetype: Big Tech, Enterprise Captive, Product Startup

Answer

Short answer

A composite gives leaves and containers one interface so callers recurse without branching. The two decisions that matter are whether child management appears on that shared interface, and which operations genuinely aggregate - because price, availability and delivery date do not combine the same way.

Was this answer helpful?

Likely follow-ups

  • A bundle ends up inside itself through three intermediate bundles. Where does your check catch it, and what does that check cost?
  • Prices must round to the penny. Do you round per leaf or once at the top, and what does each choice break?
  • How would you persist this tree, and which query does your choice make expensive?
  • Most of the tree is unchanged between two requests. What is safe to cache and what is not?

Related questions