Interface
PronunciationIN-ter-fays
Definition
A contract that lists what methods or properties something must provide, without saying how they work.
Where you hear it
TypeScript, Java, and discussions about writing code that is easy to swap and test.
Examples
Both payment providers implement the same
PaymentGatewayinterface.Code against the interface, not the implementation.
The report accepts anything that implements the Exporter interface, such as CSV or PDF.
Common mistake
Confusing it with UI. In programming, "interface" often has nothing to do with screens.
Don't confuse with
An interface is a contract that defines what methods must exist, while an abstract class can provide actual implementation code and shared state for subclasses.
Say it at work
- In a meeting or chat
Let us define a clean interface for this service so we can easily swap the database later.
- In an email or ticket
Please update the repository layer to depend on the new interface rather than the concrete class.
Keep exploring
More in Programming Fundamentals