Part 19 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 time we add yet another magical item, Backstage Passes, making everything just a little worse in the process. Then, with the tests passing, we can refactor away some of the nastiness.
We also find a problem with representing items as a data class - the generated copy methods allow us to build invalid combinations of properties - so we make Item a plain old class instead.
If you like this, you’ll probably like the book Java to Kotlin, A Refactoring Guidebook http://java-to-kotlin.dev. Chapter 3 has another example of a class (Money) that doesn't work well as a data class.
Watch video Kotlin TDD - Extend and Refactor online without registration, duration hours minute second in high quality. This video was added by user Pairing with Duncan 14 May 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 163 once and liked it 18 people.