Conceptual
Login

Programming to an Interface Rather Than an Implementation

A caller declares the operations it needs as an abstract contract and holds a reference of that contract type, so any object implementing the contract can be substituted at runtime without changing the caller. After learning this a student can define an interface from a caller's required operations, write code that depends only on that interface, and swap concrete implementations without editing the code that uses them.