Base120 · Composition
Interface Contracts
Define explicit agreements about data structures and behavior between components
When to use
"Use when components need to interact and you want to enable independent evolution. Define explicit contracts (data structures, behaviors, error modes) so that changes inside one component do not break others."
Example
"A REST API contract specifies that GET /users returns an array of user objects with id, name, email. The database schema can change, the internal caching can change, the programming language can change — as long as the contract is honored, clients do not break."
Common misuse
"Contracts that are too tight (overspecify implementation details) or too loose (underspecify error cases). A good contract specifies what clients depend on and nothing more."