Python Interfaces — Middle¶
Design boundaries around what callers need, not around implementation classes.
- Use
Protocolfor behavior-based dependencies. - Use dataclasses or validated models for stable data shapes.
- Keep optional parameters rare; a growing parameter list signals a new object or use case.
- Make invalid states difficult to construct.
Type-check in CI and keep runtime validation at system boundaries.