Kt. Academy is not only about teaching Kotlin. We are great at teaching best practices too. You have probably heard about our Effective Kotlin course, but recently Włodek Krakowski joined our team of trainers with his workshops:


As for many languages, there are many free courses teaching Kotlin online. Many of them are made by JetBrains or Google, who are interested in us learning Kotlin, but there are also some made by the community members. Let’s see how you can learn Kotlin for free.

JetBrains Academy


Nowadays, because of the quarantine, many people cannot do their job. They have a lot of time, but an uncertain future. In that time, programmers seem to be doing great. Not only we can do our job remotely perfectly well, but also demand for our services grew. Willing to help those in need I decided to do what I do best: write to help people learn to code. So here is your practical plan on how to learn programming in 9 months.

Over the last years, the most common question I was asked was “How to become a programmer?”. It…


It is not uncommon to have a bigger set of elements we need to access many times. It might be:

  • A cache — data that we download from some service and then keep in local memory to access them more quickly
  • A repository with data loaded from some file
  • An in-memory repository used for different kinds of tests

Those data might represent some list of users, ids, configurations, etc. They are generally given to us as a list, and it is tempting to represent them in our memory the same way:

class NetworkUserRepo(val userService: UserService): UserRepo {…


Update: Here is the newest version of this article.

TL;DR: Enums have supporting functions like valueOf, values or enumValues what makes them easier to iterate over or serialize. Just like classes, they can have custom methods or hold data, but always one per enum value. They are perfect to represent a set of constant values. Sealed classes can hold data specific to an instance. They are perfect to represent messages or classes with a concrete set of subclasses.

Enum

When we had to represent a constant set of possible options, a classic choice was to use Enum. For instance, if our…


This was meant to be an item in the Effective Kotlin (without memes), although I decided to not include it in the final book due to limited tailrec capabilities and, well, limited utility of this modifier. The book is published and stable now and can be found both as an ebook and in-paper.

Recurrence is a useful technique that helps us simplify some algorithms. For instance, think of a function to calculate element at the n-th position in the Fibonacci sequence. Fibonacci sequence is defined as a sequence of numbers where we start from two constants and then we calculate…


Lately, the most common question people ask me is not “How are you doing?” but instead, “When Effective Kotlin will be available in print?”. I honestly do everything I can to make it as soon as possible, but when you are bound to provide high quality, you are not a big publisher, and you need to distribute worldwide, it is not easy. Although I am happy to say that since today, it is available to some degree.

Distribution from Poland

I also start an online distribution from Poland. The price is 25€ for the paperback book. …


Extension functions — functions that are used like member functions, but yet defined outside of the class — are a great feature and loved by many. Although they started being overused what leads to problems we don’t know how to solve yet. Instead, you can see how some libraries avoid those problems using tricky and smelly solutions. This is the story about the dark side of extension functions.

fun CharSequence.isBlank(): Boolean = 
length == 0 || indices.all { this[it].isWhitespace() }
" ".isBlank() // true
" :) ".isBlank() // false


Update: Here is the newest version of this article.

This is a part of the book Effective Kotlin. Conteptually, an extension of this article by the same author, that base on Item 1 from the book Effective Java by Joshoua Bloch.

The most common way for a class to allow a client to obtain an instance in Kotlin is to provide a primary constructor:

class MyLinkedList<T>(val head: T, val tail: MyLinkedList<T>?)val list = MyLinkedList(1, MyLinkedList(2, null))

Though constructors are not the only way to create objects. There are many creational design patterns for object instantiation. Most of them revolve…

Marcin Moskala

Kt. Academy creator, co-author of Android Development with Kotlin, author of open-source libraries, community activist. http://marcinmoskala.com/

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