In this article, I am going to explain how I had my first A-ha moment trying to create my Sudoku app with Jetpack Compose.

Photo by Jamie Haughton on Unsplash

As you may already know, Jetpack Compose is a multi-platform reactive declarative UI framework (and also, not just a UI framework).

Compose is great. Not just because it makes our lives easier, but because it enforces us to write functional and declarative code and makes us think about how we can make our design more composable.

In this article, I will explain how Compose’s features helped me achieve an extensible architecture for building my Sudoku app.


In this article, multiple types of synchronization, locking and thread-safety in Java and Kotlin work are explained through interactive examples.

Photo by Tomas Sobek on Unsplash

What is Synchronization?

In a multi-threaded world, we need to access shared objects across threads, and If we do not synchronize our work, unwanted situations can occur.

First let’s see a basic example of why synchronization is needed.

No synchronization, no cry

In the example above, we are launching 1000 coroutines (If you don’t know what they are, just think about them as light-weight threads) on 4 threads, and each of them, increment the global value sharedCounter 1000 times, so the final value…


There’s a great little feature in the Kotlin v1.3 that needs more attention, and that is, Kotlin Contracts!

Kotlin Contracts

To use it in your project, update you Kotlin Gradle plugin to version 1.3 (or above):

Enable Kotlin eap in gradle

Contracts (or should we say, Kontracts?)

Kotlin contracts is a great way to tell the compiler about what a function does and help it become more intelligent.

1. CallsInPlace and InvocationKind

Let’s say we have a function as below.

Kotlin Contract — What it fixes

In this example, we have a function createOnce that we know, runs the runFunction exactly once. We use this function…

Adib Faramarzi

Android Team Lead at Tapsi

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