Kotlin coding conventions denotes that we should prefer
if for binary and
when for three or more options.
whenpreferred for three or more options?
Working with referential equality check, you would have stumbled upon the concept of IntegerCache. Let’s dig deep into this private static class.
In the example, Do you know why the referential check for 200 is false while the check for 127 is true?
If you know the reason, then you can skip the below article.
To improve performace and to save Memory, IntegerCache was introduced in Java 5.
“Integer cache support the object identity semantics of autoboxing for values between -128 to 127 as required by Java Language Specification”
<activity-alias> tag is one of the most unused tags in the android manifest. The existence and benefits of it are unknown to many Android developers, even today.
Activity alias represents a symlink to an Activity. The most popular use of activity alias is to prevent the removal of the app launcher shortcut when the underlying launcher activity is changed.
💡 Activity alias has been residing inside the androiManifest.xml since API 1.
When a launcher icon shortcut is created, it is statically linked to the exact activity of the Launcher. …
httpUrlConnection(No Okhttp support; yet)
I had a quick look at the release tags in Github and the first tag 0.6 was dated 11 Aug 2015. Its been around for quite some time now. …
Kotlin Interface supports default implementation. Which implies that we can have a default implementation to all the properties and functions defined in the Interface.
Having default implementation on interface is not appreciated by many developers. We are not going to discuss about the pros and cons, but we are more interested in how Kotlin has achieved this.
Note: To keep things simple, the java code blocks used in this article is the decompiled java equivalent of the generated byte-code by the Kotlin compiler.
Lets take a basic interface
Wheels with default implementations as an example to understand the…
As the name states, a
data class is a class that holds data. The difference from the normal class is the auto-generation of some standard functionality and utility functions derived from the data itself.
Have you asked anyone this question ? “What’s the difference between a normal class and a data class ?”….
Usually their reply would be:
Little do they understand that there are few more functionalities generated along with the usually known functions.
The copy() function is…
Cold folding is a good practise while working on complex code. It helps us to be focus on the task ahead and not get distracted by unnecessary information. It also helps in organising code or hiding less useful information so one can focus on more important information.
In this blog we will focus on Regions, a small topic in code folding.
The syntax to create a custom regions starts with a comment followed by the keyword
region and end block with the comment
endregion. This can be very helpful in grouping of code and also for documentation.
The ability to work on multiple projects with different team members have always been the strong suite of people at Modulotech. Over the years we have been successful in sharing our knowledge with everyone and every project, as we have multiple contributors working towards the same goal. The journey towards this goal is not yet achieved, as the journey never ends.
Here, I would explain a small change in our big journey, our transformation from an unformatted git message to a better solution.
Every change is treated as a magic trick. We are the magicians and the audience.
It is one thing to come up with intuitive naming for String keys but its totally another to manage and organise your colors in an Android project.
The Problem :
Your colors.xml will initially have the primary, primaryDark and accent by default, based on your theme pallette.
Later you would add few colors with their proper name.
ex: white, black, red etc,.
But before you could realise, you would have started adding the location of the color, as the key, rather than the color itself.
Tech Lead Android, Modulotech