Functional Programming Java vs. Kotlin, Stateful Function Edition

Java vs. Kotlin, Stateful Function Edition

State encapsulation or lamba expression with closure when implementing stateful functions? Is Java or Kotlin better suited for either one of those 2 approaches? Let’s find out… Use case To compare implementations in Kotlin and Java, we will build a very simple feature, create a function that can count how many times it was called. …

Read Article Read More

Functional Programming Extension Function vs. Regular Function in Kotlin

Extension Function vs. Regular Function in Kotlin

I’m a big fan of extension functions in Kotlin, for me it’s another tool in our toolbox to give the developer additional options as an API designer or consumer, but this post is not about the philosophical discussion of the merits of extension functions, like the ability to chain utility functions vs. the issues that …

Read Article Read More

Functional Programming Oracle Code One: Solving the N + 1 Query Problem

Oracle Code One: Solving the N + 1 Query Problem

Back in the cold in Ottawa after a wonderful week in beautiful San Francisco for Oracle Code One 2018. I’ll write another post shortly that will go more personal, about my experience, my struggles, my good moments and a few lessons learned which hopefully some of you will relate to. But for now here is the …

Read Article Read More

Java FlatMap, the Egg of Reactive Programming

FlatMap, the Egg of Reactive Programming

Many problems we face in software development usually end up being stories in the same category as the egg of Columbus story. If you are unfamiliar with the story, here is a very quick summary (from Wikipedia): An egg of Columbus or Columbus’ egg (Italian: uovo di Colombo [ˈwɔːvo di koˈlombo]) refers to a brilliant …

Read Article Read More

Functional Programming Adapter pattern… to explain java method references?

Adapter pattern… to explain java method references?

This quick blog post was inspired by some questions I got asked about method references in Java. This is not meant to be a tutorial on java method references and their specific binding rules (static method, constructor, bound instance method, unbound instance method) as there are many great resources out there already that can be …

Read Article Read More

Kotlin When a Dog is Not Always an Animal…

When a Dog is Not Always an Animal…

This dog obviously doesn’t seems to agree with the title, but looks like the Kotlin compiler might have a different idea about this! Below is a very small experiment using the Spring Reactive Flux api from Project Reactor (version 3.1.7) to illustrate how sometimes a dog is not always an animal: It seems like directly …

Read Article Read More

Java Cascading Lambdas and Builder Pattern in Java, when 1 + 1 = 3… but not 4

Cascading Lambdas and Builder Pattern in Java, when 1 + 1 = 3… but not 4

The builder pattern is one of many well known design patterns used to manage complexity in our code. In particular, it helps us to separate an object construction from its representation, which is especially useful when we have to construct an object with a large number of fields. But what it doesn’t do well is …

Read Article Read More

Java Java Exception and Lambda Part 2 : Give power back to the compiler

Java Exception and Lambda Part 2 : Give power back to the compiler

In Part 1 of this series we talked about how lamba expressions introduced since Java 8 are mapping to functional interfaces and how the absence of any throws clause in the standard functional interfaces provided in the JDK somewhat opened the door to the idea of exploiting the sneaky throw technique. We also found how dangerous …

Read Article Read More

Java Java Exception and Lambda Part 1 : To go sneaky or not?

Java Exception and Lambda Part 1 : To go sneaky or not?

Saying that there is a raging debate over the Internet among java developers about how to handle exceptions with java 8 lamba expressions might be a bit strong, but there is definitely an ongoing discussion and various points of view on the subject, so in the spirit of adding a little fuel to the fire, …

Read Article Read More