Kotlin Value Classes (previously known as Inline Classes) are a fine way of implementing tiny types to give type safety in function signatures and reduce errors, but they cannot be used directly in place of the type that they wrap, making them inconvenient in many applications. Here we see that they can implement interfaces by delegation, restoring a lot of convenience.
This is Part 31 of an exploration of where a Test Driven Development implementation of the Gilded Rose stock control system might take us in Kotlin. You can see the whole series as a playlist
• All Gilded Rose Episodes
and the code on GitHub https://github.com/dmcg/gilded-rose-tdd
This sub-series on error handling is also a playlist
• Kotlin Error Handling - Exceptions, N...
You can read more about tiny types and partial functions on my blog http://oneeyedmen.com/failure-is-not-...
As far as I can see, Darren Hobbs coined the term Tiny Types https://darrenhobbs.com/2007/04/11/ti...
If you like this, you’ll probably like the book Java to Kotlin, A Refactoring Guidebook
http://java-to-kotlin.dev. Chapter 19 covers error handling.
Watch video Kotlin Value Classes - Enhancing Tiny Types by Delegation online without registration, duration hours minute second in high quality. This video was added by user Pairing with Duncan 02 August 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 732 once and liked it 40 people.