Interface-oriented design (IOD) defines contracts between components before implementation. Dependent services interact through those contracts, allowing implementations to be swapped without changing integrations. section 4.1.2
Listing 4.3 Interface approach to allow implementation freedom
public interface PaymentProcessor {
PaymentResult charge(BigDecimal amount);
}
// Implementation details come later
// Could be DebitCardPaymentProcessor, CreditCardPaymentProcessor, etc.
A payment processor contract specifies a charge operation while leaving the implementation open to alternatives. section 4.1.2
Use interfaces when there is evidence that implementations will need to change. Speculative contracts can become unused inventory, adding overhead without providing useful flexibility. section 4.1.2 section 4.1
