Tag: Kotlin

What exactly did Kotlin learn from Java?

JetBrains, the genius folks who gave us IntelliJ IDEA, pulls back the curtain on Kotlin — a fresh-faced, eager programming language ready to take on the world. Fast-forward a decade, and this rookie has carved out a niche in the coding big leagues, securing a spot in the TIOBE Index&rs...

Enhance Your Kotlin Apps: A Guide to Smart Caching Solutions

TL;DR — Caches discusses the problems with caching, such as coupling and maintainability, and proposes solutions like using an object mediator, testing invalidation scenarios, and modeling real-world cache metaphors. It concludes that caches should be functional, and intelligent, and domain ob...

Sealed Classes and Enums in Kotlin: Your Guide to Cleaner Code

Today, we’re diving into the wonderful world of enums and sealed classes — two trusty tools that can make your coding life a whole lot smoother. Enums Think of enums as a special type of box where you put crayons of different colors. Each crayon can only be one of the colors you&rs...

Kotlin SOLID Principles

Many Kotlin developers do not have full knowledge of SOLID principles, and even if they know, they are not aware of why it is used. Are you ready to learn all the details? Introduction Hello Dear Kotlin lovers! Welcome to my new article. Today I am going to talk about SOLID principles in Kotli...

Why Migrate Your Build Configurations from Groovy to Kotlin DSL(KTS)?

Hey, Android Devs  I hope that you are recently seeing posts & videos regarding the migration of build.gradlefrom Groovy to Kotlin DSL(KTS). I have decided to learn more about Kotlin DSL(KTS), what are the benefits and harms of Kotlin DSL instead of Groovy? Should w...

Amplifying Flavor Customization with Kotlin Extensions: Crafting Tailored Experiences

Kotlin stands out for its elegance, conciseness, and versatility. One of its most remarkable features is extensions, which empower developers to augment existing classes with new functionality without altering their source code. Today I will show how we can use the Kotlin extension for different ...

ShareIn vs StateIn in Kotlin Flows When to Use Each

Kotlin Flows are a powerful tool for building reactive and asynchronous applications. With Flows, you can easily handle streams of data that can be consumed by one or more collectors. When multiple collectors need to consume the same Flow, it’s important to use the right function to share the ...

Data Objects in Kotlin

Data objects are a new Kotlin language feature introduced in version 1.7.20 and are currently planned to be released in version 1.9. We’ll take a closer look at what they are and what issue they are trying to solve. What issue are data objects solving? Below we have a typi...

How does Kotlin Coroutines handle structured concurrency?

We’ll dive into the world of Kotlin coroutines and explore how they handle structured concurrency. Don’t worry if you’re not a technical person; I’ll make sure to explain everything clearly and give real-life examples to make it easier to understand. Let say you’re a...

10 Useful Kotlin Extension Functions for Android Developers

Thanks for showing your love for the Kotlin extension functions in the first part. I would like to share more extensions to help you improve your programming experience with Android and Kotlin. If you have not read it yet, you can check it out at the link below. 10 Useful Kotlin Extension Functio...

Enum Classes and Sealed Classes in Kotlin

When developing applications,  ensuring the accuracy of data representation and controlling program behavior are crucial aspects of maintaining code quality. Two powerful tools that Kotlin offers to achieve these goals are Enum Classes  and Sealed Classes  In this article, we will exp...

Choosing the Right Tech for Android Development: Java, Kotlin, Flutter, and React Native

In the swiftly evolving realm of mobile app creation, the choices you make regarding technology wield substantial influence over your project’s triumph and efficiency. Within the domain of Android app development, a handful of alternatives rise to prominence: Java, Kotlin, Flutter, and Re...

State Flow and Shared Flow in Kotlin

State Flow StateFlow is a state-holder observable flow that emits the current and new state updates to its collectors. A SharedFlow that represents a read-only state with a single updatable data value that emits updates to the value to its collectors. State flow is designed to be a mo...

Decoding Fluent and Fun Clean Architecture using Kotlin

Now, we are diving deep into the essence of Fluent and Fun Clean Architecture. We’ll decode the reasons behind their design and uncover how they bring expressive code, allowing us to reap the best of benefits in our Android projects. Throughout this article, we’ll explore the core pri...

Kotlin Flow

Kotlin Flow is a reactive stream processing library for Kotlin that provides a way to emit and consume streams of data asynchronously and efficiently. It is designed to be used with Kotlin coroutines, which are lightweight threads that allow for easy and efficient concurrency. Kotlin Flow is simi...

Mastering Kotlin Channels: From Beginner to Pro - Part 1

Kotlin Channels are a powerful concurrency construct that enables communication between two or more coroutines. They provide a way to coordinate between different parts of an application, allowing them to share data and work together without interfering with each other. In this series of posts, we w...

API Calls with Retrofit in Android Kotlin: A Comprehensive Guide

In the world of modern software development, communication between different software components is crucial. One of the most common ways to achieve this is through APIs (Application Programming Interfaces). When it comes to making API calls in Android app development, Retrofit has become the go-to l...

Exceptions in coroutines

We, developers, usually spend a lot of time polishing the happy path of our app. However, it’s equally important to provide a proper user experience whenever things don’t go as expected. On one hand, seeing an application crash is a bad experience for the user; on the other hand, showing...

Exceptions in coroutines

We, developers, usually spend a lot of time polishing the happy path of our app. However, it’s equally important to provide a proper user experience whenever things don’t go as expected. On one hand, seeing an application crash is a bad experience for the user; on the other hand, showing...

Mastering RecyclerView in Android with Kotlin

RecyclerView is a powerful and versatile widget in Android development, designed to efficiently display large sets of data. With its flexibility, it replaces the traditional ListView and GridView, providing better performance and customization options. This article aims to guide you through the proc...

Writing Swift-friendly Kotlin Multiplatform APIs — Part V: Exceptions

The machine has just dispensed your expresso. You grab your cup, and, suddenly you notice a Macbook Pro with a Swift-logo sticker rushing in your direction. An angry face emerges from behind the laptop: “It’s crashing!”. Your iOS teammate turns the screen at you, pointing to somet...

== vs === in kotlin(polymorphism behaviour)

one line answer is === will use in data classes in kotlin. * I will try to explain == vs === operator use cases in Kotlin with respect to polymorphism(“Think like a compiler and act like a run-time environment”) * == shows different behaviour based on how we call, for example...

How to handle search API call on text change

In this article, we will learn how we can implement search efficiently in Android. Whenever user search for something in your app, we show a list of suggestions they might be searching for on each txt change. Let’s take an example: In the medium app when we are searching for people, ...

Mutex Mutual Exclusion in Kotlin Synchronizing Concurrent Access

In concurrent programming, multiple threads often access shared resources concurrently, which can lead to unexpected behavior and data corruption. To ensure safe access and prevent race conditions, Kotlin provides a mechanism called “Mutex” (short for mutual exclusion). A Mutex is a sync...

5 Kotlin Tips for a Cleaner Codebase

Kotlin offers a lot of useful concepts and structures that make it easy to write concise code. But when working in a team, the primary goal should be to write code that is easy to read, understand and maintain. We’re going to take a look at a few good practices that should maintain a healthier...

Java To Kotlin : Manual Steps to convert the code

In the 2017 Google I/O conference, Kotlin was announced as an official language for Android app development. it is a powerful and versatile language that is well-suited for a variety of development tasks. Also, Kotlin is interoperable with Java, making it easy to convert existing Java code...

Get current location with latitude and longtitude using kotlin

This tutorial about get current location with latitude and longtitude using kotlin. 2. Add permission in manifest <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION&...

Exploring Kotlin Generics: Writing Flexible and Reusable Code

Generics is a powerful feature in programming languages that allows you to write flexible and reusable code by introducing type parameters. Kotlin, being a statically typed language, provides robust support for generics, enabling you to create generic classes, functions, and interfaces. By leveragin...

Write your First Line of Code in Kotlin for Android!

In 2017, Google announced Kotlin as an official programming language for Android development. At the Google I/O conference held in May 2017, Google declared Kotlin a first-class language for Android app development, alongside Java. This means developers can use Kotlin to build Android applications w...

Top 10 Kotlin Interview Questions/Problems

Kotlin is an influential programming language that combines both the functional and object-oriented programming paradigms. It is notably known for its succinct syntax and its seamless interoperability with Java. This has made Kotlin a popular choice for Android development. If you’re preparing...

The Big Difference Between Flows and Channels in Kotlin

Maybe you’ve heard Kotlin programmers say that “channels are hot, flows are cold.” It’s a useful distinction between two ways of working with an asynchronous data stream. Flows and channels are as different as functions and objects. But that’s not the whole story, be...

What exactly did Kotlin learn from Java?

JetBrains, the genius folks who gave us IntelliJ IDEA, pulls back the curtain on Kotlin — a fresh-faced, eager programming language ready to take on the world. Fast-forward a decade, and this rookie has carved out a niche in the coding big leagues, securing a spot in the TIOBE Index&rs...

Different Ways to Achieve Function Composition in Kotlin

Have you ever thought about programming as a bit like playing chess, where every choice you make can lead to either a win or a loss? Well, in the world of coding, function composition is the special technique that lets you blend simple actions together, kind of like how chess pieces come together in...

Kotlin underrated feature of Distinct and DistinctBy

Recently I got to know about kotlin feature for removing duplicate from a list. Here is more detailed example of using the distinct and distinctBy methods in Kotlin to remove duplicates from a list: data class Item(val id: Int, val name: String) fun main() { val it...

The Big Difference Between Flows and Channels in Kotlin

Maybe you’ve heard Kotlin programmers say that “channels are hot, flows are cold.” It’s a useful distinction between two ways of working with an asynchronous data stream. Flows and channels are as different as functions and objects. But that’s not the whole story, be...

Shimmer effect in Kotlin with example

I recently wrote about how to improve your UI/UX withhelp of ViewPropertyAnimator. Another way to enrich the user experience — adding shimmer effect to the app. Shimmer effect is a technique used to create loading animations in applications. It is essentially a flicker that appears on ...

Typed Error Handling in Kotlin

Error handling is not rocket science. It is simple, but not always straightforward. This article studies some popular logical error handling patterns in Kotlin programming language. We will look into practical examples and the impact they might have to the cognitive complexity and maintainability of...

Understanding the Differences Between Activities and Fragments in Kotlin

In the world of Android app development, Activities and Fragments are two fundamental building blocks that serve as the backbone of any application. Both Activities and Fragments play a pivotal role in creating a seamless and interactive user experience, but they serve different purposes and have un...

Kotlin Functions Every Developer Should Know with Examples

Certainly! Here’s a collection of essential Kotlin functions that every developer should know, along with examples for each function: let: Use let to execute a block of code on a non-null object. val name: String? = "John" name?.let { println(&qu...

Kotlin Performance Tuning: 20 Best Practices You Should Know

Performance is a critical metric that can make or break your application. While Kotlin offers a plethora of features to make development easier, knowing how to leverage them for performance can be a game-changer. This article provides 20 tips that will help you write high-performance Kotlin code. ...

Mastering Kotlin: A Collection of Essential Functions Every Developer Should Know with Examples — — -Part 4 -Flattening

Flattening in general is removing the nestedness in a collection. Consider you are given a list of lists. If you want to remove all child lists and get their elements into one single-level list, you need to flatten that list. Let’s begin with : .flatten() This is the most simple w...

Currying in Kotlin

Currying is a programming technique that involves transforming a function that takes multiple arguments into a series of functions that take a single argument. In other words, it’s a way of breaking down a complex function into smaller, simpler functions that can be composed together...

Data Objects in Kotlin

Data objects are a new Kotlin language feature introduced in version 1.7.20 and are currently planned to be released in version 1.9. We’ll take a closer look at what they are and what issue they are trying to solve. What issue are data objects solving? Below we have a typi...

Top Kotlin Interview Questions You Must Know in 2023

Hey there! This post will walk through some common Kotlin interview questions any developer should know in 2023. Whether you’re getting ready for an interview or simply want to test your skills, try answering these questions to challenge yourself! Introduction Kotlin is Goog...

Idiomatic Kotlin: Merge Two Strings Alternately + Benchmarks

Hi Guys, It has been a while since I wrote an article and there have been a lot of changes going through Android and Kotlin Community from Compose to Kotlin Multiplatform, all things are exciting and fun but due to major changes in my life going on too I am not getting enough time to write some majo...

Writing Swift-Friendly Kotlin Multiplatform APIs — Part I: Intro

Kotlin Multi-Platform Mobile (KMM) is awesome… for Android developers. Using or coding a KMM library is not much different from using a regular Kotlin library like Jetpack Compose, OkHttp, and whatnot. However, for iOS developers, the story can be different. Therefore, it is essential to get ...

Programming with Kotlin in Visual Studio Code

Kotlin is all the rage now that it has been deemed a first-class programming language for developing Android apps. Actually, it’s been raging all on its own for a while now, as evidenced by the Stack Overflow Trends chart below. Kotlin Gains in Popularity (source:...