Posts by Year

2024

Back to Top ↑

2023

Coroutine Launch vs Async

3 minute read

If you are new to coroutine or looking for the continuation, you could start from the previous article.

Back to Top ↑

2022

Late initialization

2 minute read

Sometimes, we want to initialize the properties of the class after it is created, but in a separate member function instead of using lazy

Property Delegation Tools

1 minute read

The standard library contains special property delegation properties. Map is one of the few types in Kotlin library. Each property identifier becomes a Strin...

Property Delegation

2 minute read

In Kotlin, we could connect a property to a delegate with the by keyword:

Operator Overloading

3 minute read

Back in the school while I was learning C++, operator overloading was one of the topics in academic. But in practice, I rarely overload operators. However, i...

Generics in Kotlin

7 minute read

I love template in C++ in the olden day. In many good languages that I had chance to come across, such as TypeScript, Java (it was added later) and Kotlin, t...

Scope function

2 minute read

When I started doing Kotlin, the one that confused me the most was scope functions. However, once I understand what it is, it becomes my most favorite Kotlin...

Extension lambdas

4 minute read

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Resource Cleanup

less than 1 minute read

Using try, catch and finally blocks for resource cleanup is tedious and error-prone. In fact, Kotlin has a library functions that could help us to manage cle...

Nothing

less than 1 minute read

What is Nothing in Kotlin? Does it even exist? A Nothing return type indicates a function that never returns. This is usually a function that always throws a...

Check Instructions

1 minute read

Check Instructions are like assert - they act like a constraints that must be met before it could proceed. Usually, they are used to validate function argume...

Sealed class in Kotlin

1 minute read

To constrain a class hierarchy, we have to declare the superclass sealed. Without the constraint, our code will look like this:

Downcasting

1 minute read

Downcasting is to discover the specific type of a previously upcast object. Upcast is always safe because the base class cannot have a bigger interface than ...

Composition

2 minute read

One of most compelling arguments for object oriented programming is code reuse.

Another look in Inheritance

2 minute read

We touched a bit on Inheritance concept. Inheritance is sometimes used to add functions to a class as a way of reuse for a new purpose.

Back to Top ↑

2021

Polymorphism

1 minute read

One of the Object Oriented Programming concept is the ability of polymorphism. The word, polymorphism is an ancient Greek term. It means many forms. In progr...

Abstract or Interface

1 minute read

An abstract class is like an ordinary class except one or more functions or properties is incomplete - ie. a function without implementation or a property wi...

Ask for inheritance

less than 1 minute read

Inheritance is a mechanism for creating a new class by reusing and modifying an existing class.

Folding and Reducing List

1 minute read

fold() combines all elements of a list, in order to generate a single result. Here is how we can use fold() to calculate the sum -

Elegant Local Function

1 minute read

What exactly is local function? It was new to me in Kotlin and thought it is interesting to dig deeper. In a normal class, we have many functions within a cl...

Sequence: lazy evaluation

2 minute read

What is Sequence? A Kotlin Sequence is like a List, but you can only iterate. You cannot index into Sequence. And this restriction produces very efficient ch...

Higher-Order Function

less than 1 minute read

What is it? If you are coming from JavaScript, this concept may sound familiar to you. Otherwise, here is what it means.

Why Lambda

2 minute read

To some people, lambda may seem like syntax sugar, but it is more than that. If you have to repeat some codes with minor modification, you can leverage on th...

Kotlin Lambda

1 minute read

The unavoidable price of reliability is simplicity – C.A.R Hoare

Backlog Refinement Mentality

1 minute read

It is the ongoing effort by the whole team needed within each sprint to refine items in the backlog to be ready to ready for future sprints. There are a numb...

Elvis operator in Kotlin

less than 1 minute read

This operator is a question mark followed by a colon (?:) with no space in between. It is named for an emoticon (short form of “emotion icon”) of the musicia...

Team

1 minute read

Forming a team

Destructuring

1 minute read

Many times, you may encounter use cases where you need to return more than one item from a function. One way that people usually do is to create a custom obj...

When expression

1 minute read

A large part of computer programming is performing an action when a pattern matches.

Data class

1 minute read

One of main motivation of Kotlin is to reduce repetitive coding. One that many of us have spent a significant amount of time and effort is the class mechanis...

Extension function is a magic

less than 1 minute read

This is one of my most favorite features of Kotlin - Extension Function. Imagine this. You are using a 3rd party library - String that have all the things th...

Property Accessor

less than 1 minute read

If you are new to Kotlin, there is something in property accessor that you might find it interesting. There are two methods - get() for getter and set() for ...

Map in Kotlin

less than 1 minute read

So we have seen the wonderful Set. Next, we are going to look at Map.

Why package

less than 1 minute read

A fundamental principle in programming is the acronym DRY: Don't Repeat Yourself.

Set

less than 1 minute read

In computer science, Set is an interesting abstract data type that stores unique values. It is a collection that allows only one element of each value.

Infix notation in function

less than 1 minute read

Another Kotlin treasure that I have not known is the ability to write infix notation in function. We use infix notation in most arithmetic operation such as ...

Variable Argument Lists

less than 1 minute read

Do you know what vararg keyword is? Using this vararg, you can define a function that takes any number of argument.

Kotlin testing framework

1 minute read

Alright. Who here think that testing is optional? Even though some doesn’t write tests, I believe no one will openly say so. Oops. it hurts.

If expression in String templates

less than 1 minute read

You can insert a value within a String using String templates. Remember to use a $ before the identifier name:

If expression

less than 1 minute read

One of basic things that gives me a spark in the eye is when I realise in Kotlin that:

2 Most Celebrated Kotlin Features

2 minute read

While there are many great features in Kotlin language, there are two features which are very impactful and outstanding.

Why Kotlin

2 minute read

Why Kotlin? I mean why we need Kotlin in this world. Don’t we have enough of programming language already? This was exactly the question that I have when Kot...

Back to Top ↑