An Interface Defined by Supported Operations
Some interfaces describe the operations an object supports without requiring a shared named base class.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Supply the operation you need
A reporting function may require an object with a write operation accepting text. An in-memory writer and a file handle can both provide that capability. A reader test double applies the same substitution at an input interface.
Document behavior beyond the name
A write method accepting bytes or returning before completing a different operation may have an incompatible contract. Include types, expected effects, and error behavior in the function contract the consumer relies on.[1]