In which I argue the case for Kotlin’s Companion Objects being the Clark Kent of language features, in being deceptively powerful, and how we can use them in creating ways to supercharge our API design.


“Companion Objects are not just placeholders for constants and other static state; they allow for new strategies to help organise our code or to provide reusable factory and validation features.”

Image by Colin Behrens from Pixabay

Of all the features that developers enthuse about in the Kotlin world, one of the ones that you hear about least is the humble Companion Object. On the face of it, they are merely a…

In which I describe a pattern for writing third party adapters in a modular and extensible way, hoping that it is original enough for me to christen it. 🙃


“Breaking down monolithic remote API adapters into individual Actions sharing a common single-function Protocol interface allows them to not only be more decoupled at the code layer, but also simplifies both testing and extensibility.”

smash egg

Reader Note: whilst this post is about a pattern that is not Kotlin-specific, it does demonstrate the pattern using code written in Kotlin. This uses various language features such as Data classes, Companion Objects, Operator overloading and…

David Denton

Engineering Lead // Open Source // Trainer // Speaker // Kotlin GDE // Co-creator of http4k

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store