Georg Dresler

Tackling Complexity With Functional Programming And Kotlin

What if your type system could eliminate entire classes of runtime errors? Learn how functional patterns in Kotlin make illegal states unrepresentable, leading to more robust code.

Tackling Complexity With Functional Programming And Kotlin
#1about 3 minutes

Understanding a complex and unusual feature request

A real-world example of a complex feature request involves an offline form editor that syncs data via JSON embedded in PDF metadata.

#2about 3 minutes

Why traditional try-catch blocks fail for complex errors

Traditional try-catch blocks for error handling either obscure an error's origin or make the code unreadable with excessive boilerplate.

#3about 7 minutes

Using the Either type for robust functional error handling

Replace exceptions with the `Either` sealed class, using `flatMap` to chain successful operations and `fold` to handle the final success or error state.

#4about 4 minutes

Enforcing data validation using private constructors in Kotlin

Use a private constructor combined with a companion object's `invoke` operator to run validation logic upon object creation, preventing invalid states.

#5about 7 minutes

Modeling distinct data states with algebraic data types

Use sealed classes (sum types) to model different states like `Draft` and `Validated`, letting the compiler enforce state-specific logic instead of relying on boolean flags.

#6about 4 minutes

Recap of functional techniques and audience Q&A

A summary of using `Either` for errors, private constructors for validation, and ADTs for state, followed by a Q&A on libraries like Arrow and custom exceptions.

Related jobs
Jobs that call for the skills explored in this talk.

Featured Partners

Related Articles

View all articles
BR
Benjamin Ruschin
What Developers Really Need to Create Great Code Demos
Every developer on earth has, at some point, had another developer to thank for a breakthrough, a success, an aha moment they wouldn’t have had without coming across that blog post, that open-source contribution, that reply on socials or that humble ...
What Developers Really Need to Create Great Code Demos
DC
Daniel Cranney
Dev Digest 188: CfP time, the risks of NPM and IKEA algorithms
Inside last week’s Dev Digest 188 . 🤖 GitHub Copilot CLI is now in public review 💻 Microsoft is bringing ‘vibe working’ to office apps 🎣 Attackers abuse AI tools to generate captchas in fishing attacks ⚠️ When LLMs autonomously attack 🧠 Common cause...
Dev Digest 188: CfP time, the risks of NPM and IKEA algorithms
DC
Daniel Cranney
How to Avoid Over-Engineering
In today’s software development world, the demand for designing applications that are both robust and easy to maintain is more pressing than ever. Many developers encounter the architectural chaos left behind in older codebases, leading to frustratio...
How to Avoid Over-Engineering

From learning to earning

Jobs that call for the skills explored in this talk.