Extract Interface

Domain: Refactoring

🎯 Motivation

When multiple classes share behavior but no common parent, extracting an interface formalizes the contract. This enables polymorphism and easier testing through fakes or mocks.

πŸ“‹ Concrete Example

CreditCardProcessor and PayPalProcessor both have charge(amount). Extract an IPaymentProcessor interface so Checkout can accept either, and tests inject a FakeProcessor.

πŸ”— Analogy

Different phone brands agree on what a β€œcharger port” means even though their phones differ. The standard interface lets any charger work with any compatible phone.