Skip to content
0:00 / 0:00

#eventsourcing#kotlin#tdd

Functional Kotlin - Simple Event Sourcing

Pairing with Duncan

4.5K subscribers • 15 videos on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Presented by Duncan
  • Linked in the descriptiondmcg/gilded-rose-tdd

Intermediate. Assumes working knowledge.

2.5K views3 years ago1 recommendation

Programming languagesSoftware designKotlinFunctional programmingSoftware architecture

Duncan demonstrates how to implement a simple event sourcing architecture in Kotlin using functional programming principles.

Up until now we have been reading our stock list from a file that is managed by another system - Excel to be precise. We would like to bring that data into a database that we own, and at the same time make us more attractive to future employers if this startup fails. Enter Event Sourcing. With Event Sourcing, instead of maintaining a database table of our stock, we store a list of the StockEvents - StockAdded, StockModified, StockRemoved. We then process the list of events to deduce the current list of items when we need to show it. This gives us a built-in audit trail, and allows us to correct mistakes or fix bugs more easily than if we modified entries in a table. As you'll see, it also gives us a place to process the complicated rules of magical item degradation rather than having to arrange a process to run once a day. This episode is inspired by my reading of Uberto Barbini's upcoming book, From Objects to Functions - pragprog.com/titles/uboop/from-objects-to-functions/ This is part 60 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 youtube.com/playlist?list=PL1ssMPpyqociJNwykAOB9_KEZVW7BW7m2 and the code on GitHub github.com/dmcg/gilded-rose-tdd If you like this, you’ll probably like my book Java to Kotlin, A Refactoring Guidebook (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. I have some free time between producing videos and working for team Gilded Rose. If you like these videos I'd like to work with you - please get in touch - duncan@oneeyedmen.com

Why it's here

1 person recommends this

What people say. Recommended as a practical demonstration of implementing event sourcing in Kotlin.

u/dmcgin r/Kotlin • Recommends

Functional Kotlin - Simple Event Sourcing