Imperative to functional and back again in Kotlin

By Maia Grotepass

Elevator Pitch

How to convert imperative code to functional by exploring ways that the Kotlin language supports both coding paradigms. We will look at a small problem to illustrate the process. Take aways: * Demo of conversion from imperative to functional * Show Kotlin functional code * Equivalent code patterns

Description

In some situation imperative coding style is better suited to the problem and in others a functional approach might feel more apt. In Kotlin the same idea can be expressed in either. If there is a mix however, how do we convert from one to the other? This talk will take a smallish problem and present an imperative solution. We will then look at the steps we can take to convert it to a functional solution and explore Kotlin support for functional programming along the way. We will look at some common patterns we see in imperative code and what the functional equivalent would be. Lastly we will briefly compare the two approaches.

Take aways:

  • Demonstration of conversion from imperative to functional
  • An overview of Kotlin support for functional programming paradigm
  • Some common code patterns and their imperative and functional equivalents

Notes

duration: 40 min target audience: Beginner to intermediate Kotlin enthusiasts This talk has not been presented at any events yet.