# 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: article

Language: en

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

Topics: [Unit testing](<https://devfeed.tech/topics/unit-testing.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [sealed interface](<https://devfeed.tech/topics/sealed-interface.md>), [Programming Language Type Systems](<https://devfeed.tech/topics/programming-language-type-systems.md>), [exhaustive matching](<https://devfeed.tech/topics/exhaustive-matching.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-quality](<https://devfeed.tech/tags/code-quality.md>), [code-review](<https://devfeed.tech/tags/code-review.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [exhaustive](<https://devfeed.tech/tags/exhaustive.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [junit](<https://devfeed.tech/tags/junit.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [parameterized-tests](<https://devfeed.tech/tags/parameterized-tests.md>), [runner](<https://devfeed.tech/tags/runner.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.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

Kotlin's sealed types let the compiler enforce exhaustive handling in `when` expressions, but JUnit does not ensure that unit tests cover every subtype passed to a function. Parameterized tests still depend on authors to supply the cases, and code review can miss omissions. The excerpt introduces a custom "Exhaustive Test Runner" intended to ensure at least one test case for each subclass of a sealed type, including subtypes added later. The supplied text ends as the article begins describing how to build it, so it does not establish the runner's implementation or usage details.

### 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](<https://devfeed.tech/sources/touchlab-enterprise-mobile-innovation-development.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [generic programming](<https://devfeed.tech/topics/generic-programming.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [class](<https://devfeed.tech/topics/class.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: article

Language: en

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

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [syntax](<https://devfeed.tech/topics/syntax.md>), [sealed interface](<https://devfeed.tech/topics/sealed-interface.md>), [interface](<https://devfeed.tech/topics/interface.md>)

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

### AI overview

Huyen Tue Dao's KotlinConf'23 talk examines idiomatic Kotlin by asking what code best solves a given problem, and the attendee's takeaway is that the choice depends on what works best for you. The excerpt says the talk uses bytecode to make Kotlin internals more concrete, covering sealed classes and interfaces, unsigned integers for values such as full-width ARGB color codes, and value classes, which can preserve a class's identity when its underlying value is primitive. The excerpt does not describe the talk's treatment of SAM conversions or other syntax named in the title.

### 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: article

Language: en

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

Topics: [sealed class](<https://devfeed.tech/topics/sealed-class.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [sealed interface](<https://devfeed.tech/topics/sealed-interface.md>), [Inheritance](<https://devfeed.tech/topics/inheritance.md>), [interface](<https://devfeed.tech/topics/interface.md>), [Exception handling](<https://devfeed.tech/topics/exception-handling.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [Custom exceptions](<https://devfeed.tech/topics/custom-exceptions.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [exception](<https://devfeed.tech/tags/exception.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [hierarchy](<https://devfeed.tech/tags/hierarchy.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [interface](<https://devfeed.tech/tags/interface.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

Kotlin sealed classes and interfaces define a bounded hierarchy whose direct subclasses are known at compile time, enabling exhaustive `when` handling without a fallback branch. The article illustrates using this for animal types and for service error results: wrapping known failures in a sealed hierarchy can make newly added cases visible to the compiler and give errors clearer domain meaning. Sealed hierarchies can include intermediate levels while retaining exhaustive handling. The author cautions that openness may be preferable in libraries when users need to add implementations, and notes that the exception-wrapping discussion is brief.

### 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

## Kotlin Native -- Using swift, not Objective-C

DevFeed: [Kotlin Native -- Using swift, not Objective-C](<https://devfeed.tech/articles/kotlin-native-using-swift-not-objective-c-26007.md>)

Original publisher: [Read original article](<https://medium.com/yazio-engineering/kotlin-native-using-swift-not-objective-c-d7742c040539?source=rss-fbf9b6d94e65------2>)

Author: Paul Woitaschek

Published: 2021-11-19T07:21:13Z

Content type: tutorial

Language: en

Sources: [Paul Woitaschek](<https://devfeed.tech/sources/stories-by-paul-woitaschek-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [Objective-C](<https://devfeed.tech/topics/objective-c.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [boilerplate](<https://devfeed.tech/tags/boilerplate.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [data-class](<https://devfeed.tech/tags/data-class.md>), [enum](<https://devfeed.tech/tags/enum.md>), [enums](<https://devfeed.tech/tags/enums.md>), [interop](<https://devfeed.tech/tags/interop.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-compiler](<https://devfeed.tech/tags/kotlin-compiler.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlin-native](<https://devfeed.tech/tags/kotlin-native.md>), [ksp](<https://devfeed.tech/tags/ksp.md>), [mapping](<https://devfeed.tech/tags/mapping.md>), [mappings](<https://devfeed.tech/tags/mappings.md>), [objective-c](<https://devfeed.tech/tags/objective-c.md>), [productivity](<https://devfeed.tech/tags/productivity.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>), [swift](<https://devfeed.tech/tags/swift.md>)

### AI overview

YAZIO uses Kotlin Native for shared feature logic, but Kotlin types exposed through Objective-C interop do not provide the Swift-native API the iOS team wants: data classes appear as classes with non-native property types, and enums and sealed classes lose their Swift enum behavior. The team has manually mapped the public API into Swift, producing a clean interface at the cost of substantial boilerplate. The excerpt proposes automating these mappings with KSP, which analyzes Kotlin symbols and enables code generation, and SwiftPoet, which generates Swift code from Kotlin. It begins an enum-generation example: derive the enum name from an annotated class, turn its contained declarations into enum cases, then build and write a Swift file. The setup details are cut off.

### Source excerpt

Kotlin Native -- Using Swift, not Objective-C At YAZIO we use Kotlin Native Extensively. The business logic of all new app features is exclusively written in Kotlin. In its core, every screen has one ViewModel which exposes a single Flow<ViewState> that the Android App and the iOS can consume to render the state. On Android, rendering the view state is no burden because it's the language we use in the Android App anyways. However this is different for iOS. While Swift does interop with Objective-C, the public API as seen from Swift is bad. A simple data class is exported as a regular class. The properties are not native Swift types. What should be a Bool becomes a KotlinBoolean. What should be come a Double becomes a KotlinDouble. But what we want is most of the times a struct with Swift types. These are the lesser evils, the greater ones are enums and sealed classes. In Objective-C, they both become regular classes. And therefore lose all the advantages they have when used from Swift. But what we want is a Swift enum. To overcome these restrictions for quite some time our iOS team has created mappings. There is a whole target, dedicated to mapping the Objective-C classes to Swift. Basically when developing a new feature, the whole public API is manually mapped to Swift. This is good because the result is a clean Swift-native API. But that's bad because it's extreme boilerplate and a real productivity killer. What if we could directly generate these mappings and use code generation to handle that for us? Turns out: There are two tools available that make it possible. The first one is KSP. It is basically a library that lets you implement a Kotlin compiler plugin and it gives you hooks to analyze the Kotlin Syntax Tree and generate code based on it. The second one is SwiftPoet. SwiftPoet is a library you can use to generate Swift code from Kotlin, similar to what KotlinPoet and JavaPoet do. Okay, let's get our handy dirty. For the basic setup, just follow the tutorial

## 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>), [interface](<https://devfeed.tech/topics/interface.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>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.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