Inline Classes Make Great Database IDs

1 · Jake Wharton · Jan. 10, 2019, midnight
Kotlin 1.3’s experimental inline class feature allows creating type-safe, semantic wrappers around values which are erased at runtime. Database IDs are a perfect use case for this functionality. Combined with SQLDelight which automatically generates model objects and APIs for querying, different table’s IDs become different types which prevent erroneous use. In modeling an app that sends payments, the domain includes customers, instruments (like debit cards and bank accounts), and payments. Thes...