Best practices that should be followed

The intention of this article will be to convince android developers (Java or Kotlin) to incorporate the following mentioned practices in how they write their source code in their personal or work projects in order to produce optimized java byte code. The benefits that the developers will reap from these practices are the following:

  • Reduce total method count, and make optimized use of 65k method count limit imposed by dex.
  • Save space and time by removing redundant bridging logic from the byte code.
  • Save space and time when using Collections library.
  • Understand how new…

A complete guide on how to setup the bottom navigation bar

Photo by Francisco Ghisletti on Unsplash

Check out all the articles in the series:
Navigating in a pure jetpack compose project — part #1
• Navigating in a pure jetpack compose project — part #2

The last article was about how to set up navigation in a project built purely in jetpack compose. To give an overview briefly:

> We created the NavController.
> We passed this NavController to the NavHost.
> The NavHost encapsulates all the composables we can navigate to.
> Each composable is assigned a unique string, aka a route.


How to use navigation component in the compose world where there are no fragments

Photo by Samuel Chenard on Unsplash

Check out all the articles in the series:
• Navigating in a pure jetpack compose project — part #1
Navigating in a pure jetpack compose project — part #2

Jetpack compose is the new kid on the block. Though its relatively new, compared to the traditional android UI toolkit, soon will come those days when projects will start migrating to jetpack compose, and more & more companies will put it as a requirement for their potential android developer. As of the publishing date of this article, the argument “will composables completely replace fragments or views?” has not been achieved…

With the introduction of Navigation component in android Jetpack library, a ton of features were offered to the developers to ease the pain of arduous Fragment transactions and manually managing the back stack. Sure one can still do it, but given the detail of the Navigation component’s API, it would be a smart idea to let the library do the heavy lifting.

Some of the features that navigation component offers to the developers are:

Automatic fragment Transactions.
Automatic Back stack management.
SafeArgs plugin offers Null checks and Type casts for passed arguments.
Single resource file for navigation.

This is no…

Photo by Dayne Topkin on Unsplash

Java default visibility modifier for its elements is ‘protected’. ‘Protected’ means that those elements have package level visibility, which in turn means only elements in the same package are allowed to use the element marked with ‘protected’ visibility modifier. This made sure that your classes present in a different package cannot accidently use class from a different package. But here walks in Kotlin, making the elements default visibility modifier ‘public’. Sounds like a small change, but its not. It’s a major change. A change which can cause havoc if you are not cautious with the way you are exposing your…

Annotation processing
Annotation processing

Annotations provide metadata to our code. This metadata is only relevant to the scope of development and to the developer. In the absence of an annotation, this metadata information would have to be “squeezed” in our code by other means, such as naming conventions for example. To save the source code from such travesties, Java came up with the ‘Annotations API’ in JAVA 1.5 or version 5 (Java 1.6 brought complete annotations support). With the help of annotations, we can include this metadata information in different “elements” of our source code. These elements can be any of the following:


Photo by Markus Spiske on Unsplash

Kotlin and Swift are currently the top two choices of language for Android and iOS respectively. Both have been successfully adopted by their respective communities of developers who use these sharp languages to create some amazing pieces of work. Even though these two languages have their own trademark, underneath it is all the same with different names for legal purposes:

Structures offered by Swift can be created as Data Structures in Kotlin by enforcing the kotlin classes to follow some rules.Protocols in Swift is Interfaces in Kotlin.Both languages allow functional programming.Kotlin has sealed classes, however Swift has…

Photo by Danielle MacInnes on Unsplash

Anyone who has worked on a mid to large sized project, has experienced the phenomena when the changes you made for the day are not present the next day when you touch the codebase as your work got overwritten by someone else. This is what know as “The Morning After Syndrome”. Today we will do the RCA for this and try to understand how we can solve this issue in our projects.

Root Cause — Presence of a Cyclic Dependency Graph in your components.

Writing code is fun. Maintaining it is not so. Statistically speaking, most of a developer’s time goes into reading the code than writing it. It sounds counterintuitive but it’s actually not if you think about it.You can make new features after every sprint if you follow agile practices, however during that sprint period, you will still try to spend time understanding how this new feature will fit into the ‘grand scheme’ and spend most of your mind cycles thinking what needs to be changed and what doesn’t. I believe, that is where clean architecture comes into play.

To simply put…

Unravelling the mystery of recycler view functioning

This article assumes that you are aware of the following components:

  1. What is a recyclerview in android.
  2. ViewHolder.
  3. Data class.
  4. Layout Managers.

Layout Managers — The real culprit that adds complexity

I had a lotta trouble in the beginning in understanding the functioning and working of the recyclerview. The most common one was who is calling the onCreateViewHolder() and onBindViewHolder()? Is it the widget itself? Is the adapter calling it?

After a thorough investigation in the android developer guides, I found out why i was not able to wrap my head around the entity that is called the recyclerview. As you can…

Karan Dhillon

Mobile Engineer (Android) Twitter: @karandhillon95

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