# sealed-classes

Published articles for sealed-classes.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Automating Exhaustive Branch Coverage for Sealed Types in Kotlin

DevFeed: [Automating Exhaustive Branch Coverage for Sealed Types in Kotlin](<https://devfeed.tech/articles/automating-exhaustive-branch-coverage-for-sealed-types-in-kotlin-20458.md>)

Original publisher: [Read original article](<https://eng.wealthfront.com/2025/11/20/sealed-tests/>)

Author: Sean Amos

Published: 2025-11-20T16:33:33Z

Content type: tutorial

Language: en

Sources: [Wealthfront](<https://devfeed.tech/sources/wealthfront.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Unit testing](<https://devfeed.tech/topics/unit-testing.md>), [test-coverage](<https://devfeed.tech/topics/test-coverage.md>), [Code quality](<https://devfeed.tech/topics/code-quality.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [automation](<https://devfeed.tech/tags/automation.md>), [code](<https://devfeed.tech/tags/code.md>), [code-quality](<https://devfeed.tech/tags/code-quality.md>), [exhaustive](<https://devfeed.tech/tags/exhaustive.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [sealed](<https://devfeed.tech/tags/sealed.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>), [subtype](<https://devfeed.tech/tags/subtype.md>), [test-coverage](<https://devfeed.tech/tags/test-coverage.md>), [testing](<https://devfeed.tech/tags/testing.md>), [unit-testing](<https://devfeed.tech/tags/unit-testing.md>), [wealthfront-engineering](<https://devfeed.tech/tags/wealthfront-engineering.md>)

### AI overview

This article explains how to build an Exhaustive Test Runner for Kotlin sealed classes and interfaces. The approach ensures that functions accepting sealed parameters have at least one unit test for each subtype, including future subtypes added to the hierarchy.

### Source excerpt

We take code correctness and code quality seriously at Wealthfront. One of the most effective ways we ensure that our code is correct is through rigorous unit testing and strong typing. In Kotlin, sealed classes and sealed interfaces offer a powerful tool to model restricted class hierarchies. They provide strong guarantees about the types in... Read more

## Sealed Generics and SKIE - Paul Hawke

DevFeed: [Sealed Generics and SKIE - Paul Hawke](<https://devfeed.tech/articles/sealed-generics-and-skie-paul-hawke-38314.md>)

Original publisher: [Read original article](<https://touchlab.co/sealed-generics-and-skie>)

Published: 2023-10-10T00:00:00Z

Content type: tutorial

Language: en

Sources: [Touchlab | Enterprise Mobile Innovation & Development](<https://devfeed.tech/sources/touchlab-enterprise-mobile-innovation-development.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [generics](<https://devfeed.tech/topics/generics.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [classes](<https://devfeed.tech/topics/classes.md>), [Xcode](<https://devfeed.tech/topics/xcode.md>)

Tags: [apis](<https://devfeed.tech/tags/apis.md>), [classes](<https://devfeed.tech/tags/classes.md>), [generics](<https://devfeed.tech/tags/generics.md>), [kmp](<https://devfeed.tech/tags/kmp.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [sealed](<https://devfeed.tech/tags/sealed.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>), [skie](<https://devfeed.tech/tags/skie.md>), [swift](<https://devfeed.tech/tags/swift.md>), [type](<https://devfeed.tech/tags/type.md>), [xcode](<https://devfeed.tech/tags/xcode.md>)

### AI overview

This tutorial explores how SKIE improves the use of Kotlin sealed classes with generics when exposing Kotlin Multiplatform code to Swift. It discusses type discovery in Xcode, Swift interoperability, and concurrency-related code paths.

### Source excerpt

Sealed Classes and Generics are both very useful for Kotlin APIs, and very painful with KMP and Swift. One of SKIE's lesser known benefits is the restoration of using Sealed Classes with generics, along with proper type discovery in Xcode.

## Sealed classes and interfaces in Kotlin

DevFeed: [Sealed classes and interfaces in Kotlin](<https://devfeed.tech/articles/sealed-classes-and-interfaces-in-kotlin-39339.md>)

Original publisher: [Read original article](<https://kt.academy/article/kfde-sealed>)

Published: 2023-09-04T00:01:00Z

Content type: tutorial

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [sealed class](<https://devfeed.tech/topics/sealed-class.md>), [sealed interface](<https://devfeed.tech/topics/sealed-interface.md>), [interface](<https://devfeed.tech/topics/interface.md>), [abstract class](<https://devfeed.tech/topics/abstract-class.md>), [Inheritance](<https://devfeed.tech/topics/inheritance.md>), [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>)

Tags: [inheritance](<https://devfeed.tech/tags/inheritance.md>), [interface](<https://devfeed.tech/tags/interface.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [polymorphism](<https://devfeed.tech/tags/polymorphism.md>), [sealed](<https://devfeed.tech/tags/sealed.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>), [sealed-interface](<https://devfeed.tech/tags/sealed-interface.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

This Kotlin tutorial explains sealed classes and sealed interfaces as restricted hierarchies whose direct subclasses are controlled. It contrasts them with regular interfaces and abstract classes, describes their package and module requirements, and explains their use in exhaustive expressions.

### Source excerpt

What are sealed classes and interfaces in Kotlin and how do we use them.

## KotlinConf'23-Dissecting Kotlin: Unsealing the Sealed, the SAM, and Other Syntax by Huyen Tue Dao

DevFeed: [KotlinConf'23-Dissecting Kotlin: Unsealing the Sealed, the SAM, and Other Syntax by Huyen Tue Dao](<https://devfeed.tech/articles/kotlinconf-23-dissecting-kotlin-unsealing-the-sealed-the-sam-and-other-syntax-by-huyen-tue-dao-27025.md>)

Original publisher: [Read original article](<https://appmattus.medium.com/kotlinconf23-dissecting-kotlin-unsealing-the-sealed-the-sam-and-other-syntax-by-huyen-tue-dao-330153f0eeac?source=rss-be40b368c57e------2>)

Author: Matthew Dolan

Published: 2023-04-14T07:42:38Z

Content type: opinion

Language: en

Sources: [Stories by Matthew Dolan on Medium](<https://devfeed.tech/sources/stories-by-matthew-dolan-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Code](<https://devfeed.tech/topics/code.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [code](<https://devfeed.tech/tags/code.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>)

### AI overview

The author reflects on Huyen Tue Dao's KotlinConf'23 talk about idiomatic Kotlin code, examining sealed classes and interfaces, unsigned integers, bytecode, and value classes. The talk's conclusion is that the best coding approach depends on the problem and the developer's needs.

### Source excerpt

KotlinConf'23 -- Dissecting Kotlin: Unsealing the Sealed, the SAM, and Other Syntax by Huyen Tue Daohttps://medium.com/media/7939209b034172cf8e3f81cfd7f162f5/href I had the pleasure of attending the fascinating talk by Huyen Tue Dao at KotlinConf'23 where she explored the question of idomatic Kotlin code. While the conclusion that "it matters what is best for you" might seem slightly disappointing, the journey to that conclusion was both informative and enlightening. What code is best to solve your problem? One of the highlights of the talk for me was when the speaker delved into the internals of Kotlin and showed us the byte code. This helped to demystify some of the more advanced concepts and made the talk feel very practical and grounded in real-world examples. The speaker started by discussing sealed classes and interfaces, and went on to cover several other interesting Kotlin features. These included unsigned integers, which are useful for representing values that need to use the full bit-width, such as color codes in ARGB format. Exploring the byte-code for unsigned types lead us to a discussion on value classes and their usefulness for maintaining the identity of a class even when the underlying value is primitive. You can find my thoughts on more KotlinConf'23 talks at KotlinConf'23. Please let me know your thoughts. Join medium to read all of my articles or subscribe for e-mail updates.

## Sealed classes in Kotlin

DevFeed: [Sealed classes in Kotlin](<https://devfeed.tech/articles/sealed-classes-in-kotlin-23690.md>)

Original publisher: [Read original article](<https://medium.com/betclic-tech/sealed-classes-in-kotlin-74b1d28aaef2?source=rss----7e406d68d94b---4>)

Author: Florian Garcia

Published: 2022-09-26T13:51:32Z

Content type: tutorial

Language: en

Sources: [betclic-tech - Medium](<https://devfeed.tech/sources/betclic-tech-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Inheritance](<https://devfeed.tech/topics/inheritance.md>), [Code](<https://devfeed.tech/topics/code.md>), [Exception](<https://devfeed.tech/topics/exception.md>)

Tags: [classes](<https://devfeed.tech/tags/classes.md>), [code](<https://devfeed.tech/tags/code.md>), [exception](<https://devfeed.tech/tags/exception.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [sealed](<https://devfeed.tech/tags/sealed.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>)

### AI overview

A tutorial explaining how Kotlin sealed classes and interfaces represent restricted class hierarchies. It shows how they help the compiler identify all supported cases and avoid missing-case handling when the hierarchy changes.

### Source excerpt

In this article, we will talk about sealed classes and interfaces. What they are, what problem they solve and how we can leverage this in real life. The problem Let's take the following code: https://medium.com/media/f1f04b5ee8f0bfc98d41cad1fbd803a2/href Our code only handles two types of animals (cats and dogs). But the compiled code does not know that only those two types exist. This means we have to add this ugly else block in our when. This can be a real issue because you start to think about what to do in a situation that shouldn't exist but that will potentially exist in the future. For instance, say that tomorrow we add cows to the list of supported animals, the code will compile just fine because we have put the else block. We could change the else part to throw an exception but Kotlin does not have checked exceptions (so it's easy to forget to catch one), and thus we end up with runtime exceptions. That's a bit sad because we probably want to know at compile time that we need to handle this new case. Solution As you probably have guessed, the solution is sealed classes or interfaces. But what are they? From the Kotlin documentation: Sealed classes and interfaces represent restricted class hierarchies that provide more control over inheritance. All direct subclasses of a sealed class are known at compile time. No other subclasses may appear after a module with the sealed class is compiled. For example, third-party clients can't extend your sealed class in their code. Thus, each instance of a sealed class has a type from a limited set that is known when this class is compiled. If rephrased, this means that we can define a bounded hierarchy. One of the important things to know when working with sealed classes is that you cannot instantiate the sealed class; thus only the leaves of the structure exist at runtime (but you can use the interface as a type). When we develop applications that are not libraries, it is pretty rare to allow an abstract class / interfac

## The story behind Apollo Kotlin 3 codegen

DevFeed: [The story behind Apollo Kotlin 3 codegen](<https://devfeed.tech/articles/the-story-behind-apollo-kotlin-3-codegen-23544.md>)

Original publisher: [Read original article](<https://www.apollographql.com/blog/the-story-behind-apollo-kotlin-3-codegen>)

Author: Martin Bonnin

Published: 2022-04-26T09:21:00Z

Content type: article

Language: en

Sources: [Apollo Blog](<https://devfeed.tech/sources/apollo-blog.md>)

Topics: [Code generation](<https://devfeed.tech/topics/code-generation.md>), [GraphQL](<https://devfeed.tech/topics/graphql.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [multiplatform](<https://devfeed.tech/topics/multiplatform.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>)

Tags: [apollo](<https://devfeed.tech/tags/apollo.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [graphql](<https://devfeed.tech/tags/graphql.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>)

### AI overview

This article explains the design and tradeoffs behind Apollo Kotlin 3 code generation. It describes the challenges of making the codebase Kotlin Multiplatform and implementing GraphQL fragments as interfaces, then compares operation-based model generation with simpler schema mappings. The article argues that operation-based models provide better type safety and compile-time verification by avoiding unnecessary nullability.

### Source excerpt

Apollo Kotlin 3 was released in December 2021. This is a significant release for Apollo Kotlin, and it's fair to say it took significant effort to reach that point 🚀. Now that Apollo Kotlin 3 is in orbit 👨🚀, it is a good time to reflect on how we got there and the different tradeoffs involved in generating type safe models from GraphQL operations. When we started Apollo Kotlin 3, we had two main goals: Our initial gut feeling was that 1. was a huge task and 2.

## Learning Zig - Day 3

DevFeed: [Learning Zig - Day 3](<https://devfeed.tech/articles/learning-zig-day-3-38542.md>)

Original publisher: [Read original article](<https://msfjarvis.dev/posts/learning-zig--day-3/>)

Author: Harsh Shandilya

Published: 2021-05-16T06:30:00Z

Content type: tutorial

Language: en

Sources: [Posts on Harsh Shandilya](<https://devfeed.tech/sources/posts-on-harsh-shandilya.md>)

Topics: [Zig](<https://devfeed.tech/topics/zig.md>), [Learning](<https://devfeed.tech/topics/learning.md>), [syntax](<https://devfeed.tech/topics/syntax.md>), [type coercion](<https://devfeed.tech/topics/type-coercion.md>), [Code](<https://devfeed.tech/topics/code.md>), [Rust](<https://devfeed.tech/topics/rust.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [enums](<https://devfeed.tech/tags/enums.md>), [learn](<https://devfeed.tech/tags/learn.md>), [learning](<https://devfeed.tech/tags/learning.md>), [pointers](<https://devfeed.tech/tags/pointers.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>), [syntax](<https://devfeed.tech/tags/syntax.md>), [type-coercion](<https://devfeed.tech/tags/type-coercion.md>), [zig](<https://devfeed.tech/tags/zig.md>)

### AI overview

A personal learning log covering the remaining basics of ZigLearn chapter 1. The author discusses Zig pointers, enums, structs, unions, type coercion, floats, and optionals, often comparing Zig's syntax and behavior with Rust and Kotlin.

### Source excerpt

Finishing up the basics

## Sealed goodies coming in Kotlin 1.5

DevFeed: [Sealed goodies coming in Kotlin 1.5](<https://devfeed.tech/articles/sealed-goodies-coming-in-kotlin-1-5-27082.md>)

Original publisher: [Read original article](<https://zsmb.co/sealed-goodies-coming-in-kotlin-1-5/>)

Author: Márton Braun

Published: 2021-01-19T14:00:00Z

Content type: article

Language: en

Sources: [zsmb.co](<https://devfeed.tech/sources/zsmb-co.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Inheritance](<https://devfeed.tech/topics/inheritance.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [classes](<https://devfeed.tech/tags/classes.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [marton-braun](<https://devfeed.tech/tags/marton-braun.md>), [pattern-matching](<https://devfeed.tech/tags/pattern-matching.md>), [preview](<https://devfeed.tech/tags/preview.md>), [sealed](<https://devfeed.tech/tags/sealed.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>), [zsmb](<https://devfeed.tech/tags/zsmb.md>), [zsmb-co](<https://devfeed.tech/tags/zsmb-co.md>), [zsmb13](<https://devfeed.tech/tags/zsmb13.md>), [zsmbco](<https://devfeed.tech/tags/zsmbco.md>)

### AI overview

This article explains Kotlin sealed classes and previews planned Kotlin 1.5 improvements, including relaxed inheritance restrictions and the introduction of sealed interfaces. It also discusses interoperability with newer Java sealed constructs.

### Source excerpt

Kotlin 1.5 will bring exciting new features, among them improvements to sealed classes and an introduction of sealed interfaces. Let's take a look at what that will look like!

## Designing and Working with Single View States on Android

DevFeed: [Designing and Working with Single View States on Android](<https://devfeed.tech/articles/designing-and-working-with-single-view-states-on-android-27060.md>)

Original publisher: [Read original article](<https://zsmb.co/designing-and-working-with-single-view-states-on-android/>)

Author: Márton Braun

Published: 2020-05-25T17:00:00Z

Content type: tutorial

Language: en

Sources: [zsmb.co](<https://devfeed.tech/sources/zsmb-co.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [App](<https://devfeed.tech/topics/app.md>), [ui](<https://devfeed.tech/topics/ui.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [data-class](<https://devfeed.tech/tags/data-class.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [marton-braun](<https://devfeed.tech/tags/marton-braun.md>), [mvi](<https://devfeed.tech/tags/mvi.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [network](<https://devfeed.tech/tags/network.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>), [state](<https://devfeed.tech/tags/state.md>), [zsmb](<https://devfeed.tech/tags/zsmb.md>), [zsmb-co](<https://devfeed.tech/tags/zsmb-co.md>), [zsmb13](<https://devfeed.tech/tags/zsmb13.md>), [zsmbco](<https://devfeed.tech/tags/zsmbco.md>)

### AI overview

This tutorial explains how to represent Android screen state with a single ViewState object. It compares a single data class with a hierarchy of sealed classes, emphasizing how sealed classes can better model mutually exclusive states such as loading, content, and error.

### Source excerpt

Describing the state of a screen is a common practice these days thanks to MVI popularizing the concept. Let's take a look at some examples of how you can design your state objects neatly using data classes and sealed classes, and how you can put them into practice.

## Abstracting Kotlin Sealed Classes

DevFeed: [Abstracting Kotlin Sealed Classes](<https://devfeed.tech/articles/abstracting-kotlin-sealed-classes-29349.md>)

Original publisher: [Read original article](<https://arturdryomov.dev/posts/abstracting-kotlin-sealed-classes/>)

Author: Artur Dryomov

Published: 2019-06-04T00:00:00Z

Content type: article

Language: en

Sources: [Artur Dryomov](<https://devfeed.tech/sources/artur-dryomov.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>), [Refactoring](<https://devfeed.tech/topics/refactoring.md>), [Java](<https://devfeed.tech/topics/java.md>)

Tags: [bytecode](<https://devfeed.tech/tags/bytecode.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [models](<https://devfeed.tech/tags/models.md>), [polymorphism](<https://devfeed.tech/tags/polymorphism.md>), [properties](<https://devfeed.tech/tags/properties.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>), [sealed](<https://devfeed.tech/tags/sealed.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>)

### AI overview

This article examines ways to declare common properties in Kotlin sealed class hierarchies. It compares approaches involving type declarations, constructors, and separate Java-rooted abstractions, including their ergonomics and generated bytecode implications.

### Source excerpt

Things tend to be similar. Cars and bikes are different for sure but both have wheels, engines, exhaust systems and so on. Such similarities between models are usually described using basic polymorphism in virtual domain modeling. Kotlin makes this process a bit more pragmatic using sealed class declarations. Specifying type hierarchies using sealed classes is simple, but what about declaring common properties? Fortunately or not there are multiple ways to achieve this -- partially because of the Java baggage. Which one is the best?

## Kotlin sealed classes and their differences from enums

DevFeed: [Kotlin sealed classes and their differences from enums](<https://devfeed.tech/articles/sealed-classes-in-kotlin-enums-with-super-powers-kad-28-27225.md>)

Original publisher: [Read original article](<https://antonioleiva.com/sealed-classes-kotlin>)

Published: 2017-06-27T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [enum](<https://devfeed.tech/topics/enum.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [compiler](<https://devfeed.tech/tags/compiler.md>), [enum](<https://devfeed.tech/tags/enum.md>), [enums](<https://devfeed.tech/tags/enums.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>)

### AI overview

A Kotlin tutorial explaining sealed classes as constrained class hierarchies. It compares them with enums, shows how subclasses can hold state, and explains compiler checking of branches when handling all possible types.

### Source excerpt

Everything Android, Kotlin and other random topics