Kotlin Value Classes - Enhancing Tiny Types by Delegation

Опубликовано: 02 Август 2022
на канале: Pairing with Duncan
732
40

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.


Смотрите видео Kotlin Value Classes - Enhancing Tiny Types by Delegation онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Pairing with Duncan 02 Август 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 732 раз и оно понравилось 40 людям.