# The Three Ideas

The Three Ideas: Find What Changes and Fence It Off, Program to an Interface, Not a Class, Prefer Composition to Inheritance.

Updated: November 17, 2026

1. [Find What Changes and Fence It Off](https://www.ask-codey.com/lessons/dp-encapsulate-what-varies) (Apprentice): When the part of a program that changes every week is mixed into the part that shouldn't change, every change risks the rest; finding what changes and giving it a home of its own, behind one wall, is the idea behind almost every design pattern, and it comes with two words worth knowing: coupling and cohesion.
2. [Program to an Interface, Not a Class](https://www.ask-codey.com/lessons/dp-program-to-an-interface) (Apprentice): When checkout asks for a card reader by name, every new way to pay means editing checkout; asking instead for "something that can take a payment", a promise any class can keep, lets a gift card, or anything else, plug in without checkout changing at all.
3. [Prefer Composition to Inheritance](https://www.ask-codey.com/lessons/dp-prefer-composition) (Apprentice): When every combination of options becomes its own subclass, the classes multiply until a burrito with extra cheese and no onion needs a class of its own; building an item from parts it holds (composition) instead of from a family tree of subclasses (inheritance) turns each new option into one new part.

Source: https://www.ask-codey.com/courses/design-patterns/topics/dp-the-three-ideas
