Kotlin Unknotting — From Realizing Anti-Patterns to Becoming a Better Developer | by Nirbhay Pherwani | Nov, 2023
Now, let’s apply our newfound wisdom to real-world scenarios. We’ll transform the previously discussed bad practices into best practices with examples that are common in advanced Kotlin development. Photo by James Lee on Unsplash A) Enhanced Nullability Handling Scenario: You’re working on a user profile…
Koin, Ktor & Paging in KMM | Compose Multiplatform | by Prashant | Nov, 2023
@Composablefun <T : Any> PagingListUI(data: LazyPagingItems<T>,content: @Composable (T) -> Unit) {LazyColumn(modifier = Modifier.fillMaxSize().background(Color.White),horizontalAlignment = Alignment.CenterHorizontally,) { items(data.itemCount) { index ->val item = data[index]item?.let { content(it) }Divider(color = UiColor.background,thickness = 10.dp,modifier = Modifier.border(border = BorderStroke(0.5.dp, Color.LightGray)))} data.loadState.apply {when {refresh is LoadStateNotLoading && data.itemCount < 1 ->…
Kotlin under the hood: How inline functions work | by Max Sidorov | Nov, 2023
I conduct a lot of technical interviews and see that many developers do not understand the benefits of using inline functions . Why is crossinline needed and how reified works. Part of the source of common misconceptions about inline functions is that there used to…
Law of Demeter with examples in Kotlin | by Fabrizio Di Napoli | Nov, 2023
Not Demeter but I liked the pic! Photo by Nils on Unsplash First of all, what is Law of Demeter? It’s also called Demeter’s law or LoD or Principle of Least Knowledge or “don’t talk to strangers”. It was discovered in 1987 in Northeastern University,…
BasicTextField2: A TextField of Dreams [1/2] | by Alejandra Stamato | Nov, 2023
Meet TextField (orBasicTextField) APIs to implement a text field in Jetpack Compose: var textField by rememberSaveable { mutableStateOf(“”) }TextField(value = textField,onValueChange = { textField = it },) This simple API has a series of shortcomings, most notably: It is way too easy to introduce async…
Dive into Kotlin Coroutines.. In this article, I’ll give some basic… | by Anatolii Frolov | Nov, 2023
First, we’ll remove all the auxiliary code to measure the execution time of the code and output the log. We don’t need this anymore. Now our coroutine will look like the example below. Let me remind you that the receiveData() function is suspended and will…
ViewModel: Events as State are an Antipattern | by Nek.12 | Nov, 2023
Credits: https://www.bing.com/images/create/an-image-of-a-child-trying-to-fit-a-circle-shaped-/6547a9b07dbb47008fe7ca37164b7e5a I feel like I need to discuss this, so I decided to write an article on a hot topic in the Kotlin dev community about one-off events antipatterns. So the story begins with this article by Manuel Vivo ViewModel: One-off event antipatterns I…
Elegant Event Handling in Kotlin — A Refactoring Walkthrough | by Sven Nähler | Nov, 2023
Unlock peak performance in Kotlin code with these expert refactoring tips. In the world of software development, code refactoring is the hero that rescues us from tangled and inefficient code. In this article, we’ll embark on an adventure to revamp Kotlin code handling diverse events….
BasicTextField2: A TextField of Dreams [2/2] | by Alejandra Stamato | Nov, 2023
In part 1️⃣ we’ve covered how to: manage state with the new BasicTextField2 APIs to prevent state synchronicity issues do basic styling including using decorator and line limits solve for common scenarios when observing state and applying business rules edit the value of the text…
Migration to Version Catalog. Version catalog enables to add and… | by Saqib | Nov, 2023
Version catalog enables to add and maintain dependencies and plugins at a central place. Photo by Mohamed Nohassi on Unsplash In a multi-module project adding dependencies individually including versions in each module build.gradle is not ideal and not a recommended approach. If you have to…