Developer Toolsjetbrains_blogAlphaLab AI score 26/100
Kotlin Function Signatures: Making Errors Explicit
Sergey Chernov, Lead Software Engineer at Salmon, advocates for making function failures explicit in Kotlin signatures to improve reliability in authentication and verification systems. In Kotlin, functions like `signDocument` often return `Unit`, equivalent to Java’s `void`, but this approach hides potential failures such as database outages, expired documents, or invalid codes. Chernov proposes using `Either` to embed expected failures directly into the function signature, ensuring that errors are visible and handled systematically. This method avoids digging through implementation details and aligns with Salmon’s engineering culture of transparency and reliability.