Implementing Interfaces with Method Maps

Published: 19 July 2024
on channel: Pairing with Duncan
811
39

Kent Beck has been writing recently on the idea of the adjacent possible and software design. The adjacent possible is the technological space that we can reach from where we are now in one hop - we don’t have to develop something intermediate before we can implement something useful.

In software, sometimes we add some code and find ourselves expanding the adjacent possible. I think that happens in this episode. I was just adding the ability to discard coroutine continuation parameters when we call one interface through another, but on refactoring that code to remove duplication, I think that I have uncovered a technique that will allow us implement the decorator pattern for interfaces by populating maps of functions.

In this episode

00:00:48 Mapping from suspend to non-suspend functions
00:02:29 Add a test
00:04:00 It fails because we are looking for a method with a continuation
00:04:26 Duplicate our current implementation and fix it to find the right method to call
00:07:56 Now fix the invocation to discard the continuation
00:09:39 Now what is trying to get out of this mess - it's first-class functions
00:14:06 Now remove some duplication
00:16:40 Now retrofit our new plan to our old code
00:19:37 We can compose creating our map if we step back a bit
00:21:51 That opens up new possibilities
00:23:21 Review

The code for this video is on a GitHub fork https://github.com/dmcg/ktor-document...

Other videos on proxies can be found in a Reflection playlist    • Reflection  

This video is in a playlist of Ktor episodes (   • Ktor  ) and http4k (   • http4k  )

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...

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 Implementing Interfaces with Method Maps online without registration, duration hours minute second in high quality. This video was added by user Pairing with Duncan 19 July 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 811 once and liked it 39 people.