As promised in my last article, here I am back again with the grid canvas we used to replicate IntelliJ IDEA’s splash screen. This time I will be explaining how to implement some additional features.

Content alignment

We want our composable to have the ability to set where the cells will be placed relative to the canvas bounds, or how the space between the grid and the canvas limits will be distributed.

This can be easily achieved with Alignment interface which contains a single align function. …

The latest version of IntelliJ IDEA (2021.1 at the time of this publication) has a cool splash screen based on a grid containing different coloured shapes like this below:

IntelliJ IDEA 2021.1 splash screen

The goal of this post is to implement a Jetpack Compose composable that mimics this pattern.

As we can see the view is a grid of five different type of cells: circle, top left quadrant, top right quadrant, bottom left quadrant and bottom right quadrant. The quadrants are just a quarter portion of a larger circle.

The way we are going to implement this is by using a Canvas. It usually…

When starting to work with Jetpack Compose (now that it is in beta 🎉) and stateful components, we easily get used to define values based on a mutable state which are also remembered. But there are two independent concepts when we write a line of code like below:

var clicks by remember { mutableStateOf(0) }
  • mutableState* family functions return an observable value for Compose. It creates a MutableState that allows Compose to magically react when the contained value changes.
  • remember on the other hand makes the computation passed to the lambda execute once (not exactly once, but just during the…

Photo by Science in HD on Unsplash

Writing stable and reliable UI tests is neither easy nor trivial. There are multiple factors applications depend on that UI developers can’t control. Network is a very common external dependency that can produce test instability. There are many reasons that make it hard to maintain a fully functional server side infrastructure:

  • Data consistency
  • Different application and server availability
  • Effort and cost of maintaining the above

A few months ago the Android team at my job decided to work on enabling UI tests. Writing tests itself is an “easy” task thanks to powerful tools like Espresso. But based on our past…

If you have been in the Android ecosystem for a while, there is a chance that at some point you needed to show a list of items on the screen grouped by a given criteria in the form of a header. Something like:

After spending the last weeks working on a library, today, I am happy to announce the first beta release of poetimizely. (Thanks to Ralph who is contributing to the project 🙂).

What is poetimizely?

poetimizely is a library to generate type safe accessors for Optimizely experiments and features.

Type safe means that referencing experiments and features are safe, reducing the possibilities of making a mistake when typing names. This makes sense because both experiments and features are part of a closed set of values (determined by whatever is defined on Optimizely).

Why should I use it?

Optimizely is a very powerful experimentation platform that I have worked with…

One of the things that feels much different in Kotlin compared to Java is the type system. The void keyword for example is not present in Kotlin, so Unit type is used instead:

fun functionReturningNoValue(): Unit {

I would say that this approach is more consistent than using a special keyword to denote functions that don’t return any value.

Types everywhere

Kotlin gives more flexibility when using throw and return as they can be evaluated to the Nothing type. This gives us the ability to use it in the use case like the one described below:

class User(val address: Address?)


This is an easy one, Any is just the “root” type, so every other type extends from it. It is like Object in Java, in fact, the compiled code for a value of type Any is an Object.

// Kotlin

val greeting: Any = "Hi there!"

// Java

private final Object greeting = "Hi there!";


A function returning Unit in Kotlin means returning void in Java. Additionally, a function returning Unit in Kotlin doesn’t explicitly need to return it. So these two functions compile to the same:

// Kotlin

fun returnsUnit(): Unit {
fun returnsUnitExplicitly(): Unit {
return Unit…

When it comes to decide between using an enum or a sealed class in Kotlin, I’ve seen several situations where developers where using them indistinctly.

Generally speaking, sealed classes are more powerful than enums. This is because a sealed class is just an abstract class which requires to define every child class in the same Kotlin source file.

Enum vs sealed class

So what are the main similarities and differences between them?

  • Both can define abstract members. In the case of the enum, each of the values will be required to implement them. …

Whenever we write a new class in Kotlin, we may feel tempted about defining as a data class. But should every class which is a data holder be a data class? I don’t think so. During the last months I have seen suggestions in PRs such as “make this class a data class?”.

Kotlin data class

Let’s see first what is Kotlin compiler generating for free when we declare a data class.

  • equals() / hashCode() => nothing fancy here, just the implementation for this well known functions.
  • toString() => a nice to see String representation of the class.
  • componentN() functions => functions that…

Patxi Bocos

Impure developer and functional programming enthusiast

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