Creating Java static final Equivalents in Kotlin 1. Overview In this quick tutorial, we’ll discuss static final variables in Java and their equivalent in Kotlin. In Java, declaring static final variables helps us create constants. And in Kotlin, we have several ways to achieve the same goal. 2. Inside an object Firstly,… Continue Reading kotlin-java-static-final

Non-blocking Spring Boot with Kotlin Coroutines 1. Overview Kotlin Coroutines can often add readability to reactive, callback-heavy code. In this tutorial, we’ll find out how to leverage these coroutines for building non-blocking Spring Boot applications. We’ll also compare the reactive and coroutine approaches. 2. Coroutine Motivation Nowadays, it is common for… Continue Reading spring-boot-kotlin-coroutines

Writing Specifications with Kotlin and Spek 1. Introduction Specification Testing frameworks are complementary to Unit Testing frameworks for testing our applications. In this tutorial, we’ll introduce the Spek framework – a Specification Testing framework for Java and Kotlin. 2. What is Specification Testing? Simply put, in Specification Testing, we start… Continue Reading kotlin-spek

Kotlin Dependency Injection with Kodein 1. Overview In this article, we’ll introduce Kodein — a pure Kotlin dependency injection (DI) framework — and compare it with other popular DI frameworks. 2. Dependency First, let’s add the Kodein dependency to our pom.xml: <dependency> <groupId>com.github.salomonbrys.kodein</groupId> <artifactId>kodein</artifactId> <version>4.1.0</version> </dependency> Please note that the… Continue Reading kotlin-kodein-dependency-injection

Generate a Random Alphanumeric String in Kotlin 1. Overview In this tutorial, we’ll discuss how to generate a random alphanumeric String in Kotlin using three different approaches: Java Random, Kotlin Random, and Apache Commons Lang RandomStringUtils. Then, we’ll wrap up with a look at a high-performance approach. 2. Dependencies Before… Continue Reading kotlin-random-alphanumeric-string