This week we’re back in our test-driven Gilded Rose codebase. For those who have only started watching recently - this is an implementation of a stock control system for a magical goods store, using Kotlin in a largely functional style, and developed iteratively over 100 episodes so far. Key technologies are Postgres via JOOQ and HTMX via http4k.
It’s been a year since we added any core functionality to the application - the ability to add a new item to stock. The system has continued to function reliably since then, but apart from updating versions of Kotlin and libraries, we haven’t added any more features because Alison, the shop owner, would rather spend her money on cruises than developers.
She would also like to make more money though, and now that she is persuaded that this Internet thing may not be a fad, she would like to explore selling online. So we’re rehired!
The system is production-quality code, and as with most codebases, we have taken on some technical debt in order to make more rapid progress. In particular we didn’t get around to removing a feature flag that controls whether or not the new item functionality is shown in the UI. Now seems like a good time to do that, so let’s do that. In fact, let’s do it twice, once the old-fangled using-refactoring-tools-way, and then again the new-fashioned AI Assistant way.
In this episode
00:01:23 Quick demo
00:01:54 Check the feature flag is always on
00:02:38 Replace the flag with its value and test
00:03:23 Remove code that referenced the value
00:04:49 Replace the flag with its value again
00:06:50 Now we can remove unused references
00:07:19 Safe delete isn't as smart as it could be
00:09:25 The same refactor with AI Assistant
00:17:12 Conclusions
There is a playlist of TDD Gilded Rose episodes - • Test Driven Gilded Rose in Kotlin
The codebase is available on GitHub https://github.com/dmcg/gilded-rose-tdd
I get lots of questions about the test progress bar. It was written by the inimitable @dmitrykandalov. To use it install his Liveplugin (https://plugins.jetbrains.com/plugin/...) and then this gist https://gist.github.com/dmcg/1f56ac39...
Thanks to Orion Williams for the music https://toolofgod.com/my-music/royalt...
If you like this video, you’ll probably like my book Java to Kotlin, A Refactoring Guidebook (http://java-to-kotlin.dev). It's about far more than just the syntax differences between the languages - it shows how to upgrade your thinking to a more functional style.
Watch video Back to Basics Kotlin Refactoring - Man vs Machine online without registration, duration hours minute second in high quality. This video was added by user Pairing with Duncan 27 September 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 754 once and liked it 39 people.