Install our extension to search inside any video instantly.

Context Parameters and API Design | Alejandro Serrano Mena

Added:
519 views39likes44:16KotlinOriginal Release: 2026-07-17

Context parameters in Kotlin are implicit function parameters that are automatically threaded by the compiler, reducing boilerplate while maintaining code readability. The 'spotlight principle' guides API design decisions: receivers should be main characters (central to the code's purpose, like builders), while context parameters should be secondary characters (dependencies that are needed but should remain unnoticed). For dependency injection, use context parameters; for builders and DSLs, use receivers; for effects like test scopes, use invisible context parameters with underscore names. This design philosophy ensures that code remains focused on its primary purpose while dependencies are handled implicitly.