Stage 1 · Code
Methods, Interfaces & Errors
Interface Practice
Build a logger and storage abstraction that demonstrates real-world interface design, mock implementations, and testable code.
Design the Interfaces
Good interfaces are discovered from usage, not designed upfront. Start with the concrete type, extract the interface when you need a second implementation or a test double.
Concrete Implementations
Concrete implementations are the real production types. They satisfy the interface implicitly by having the right methods.
Mock Implementations
A mock replaces a real implementation for testing. Because our code depends on interfaces, not concrete types, we can inject a mock without changing any production code.
Composing with Interfaces
Small interfaces compose naturally. A ReadWriter interface embeds Reader and Writer. A logging wrapper can implement Store by forwarding to another Store. These patterns appear throughout the standard library.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.