When I was ten, I spent the whole summer every year having fun, playing sports, climbing trees with my cousins. Yet, I was compaining very often - “I want to grow up fast. I’m tired of being a small kid”. Every one of my cousins told me the same. “Believe me you don’t want to. You are living your golden days” I did not believed them. Years later, I married love of my life. We had some good times…
In our busy modern lives, we often overlook the silent witnesses that have stood for centuries, observing the world change around them. These ancient trees have seen it all, from changing landscapes to the passing of generations, and if they could talk, they’d have some of the most remarkable stories to tell. Imagine a tree that has been standing for centuries, its roots delving deep into the…
I have read couple of blog posts lately about the discussion around using mocks vs fakes in the android community. I remember reading same kind of argument few years back as well. There is a strong opposition for using mocks and all of them suggest to use fakes instead. Here are some of the arguments for using fakes over mocks Mocks encourage or make it easy to expose implementation details in the…
Empathy during the code review: This is a big one for me. Always keep in mind that you are reviewing the code and not the author. I’ve been on the other side to know how it feels when the reviewer is not empathetic. If you think some piece of logic can be done in a better way. Provide concrete examples and explain why you think your example is better than theirs. Also, this should never be forced…
There are two instances of coroutine context available. One is from the CoroutineScope and the other is an instance from CoroutineContext itself. When we use coroutine builders like launch or async , we get 2 coroutine context. One from coroutinescope and another from the coroutine builder. coroutine builders take “coroutine context” as one of the parameters. coroutine builder merges its coroutine…
Go visit different countries when you can. Go do that trekking when you can. Work on your side projects when you can. Go meet your friends when you can. Pick your daughter/son up when you can. Play with your daughter/son when you can. Spend time with your parents/siblings when you can. Talk to your relatives when you can. Take the stairs instead of elevator when you can. Go workout intensely when…
Insured Declared Value (IDV) : IDV is the maximum amout that is given to the policyholder by the insurance company in case of theft or total loss of the vehicle. IDV is calculated as manufacturer’s listed selling price - Depriciation. Always try to go for maximum IDV. Zero-Depreciation-Cover: Every year the value of your vehicle keeps declining. This declining of amount is called Depriciation.…
Everyone has a smartphone and the impact is more. Users get to see, play, and enjoy our craft. Short feedback cycle for developers. You get to see the results of your work in short time. Unlike web development, mobile development comes with many constraints. What if there is no internet? Battery constraint Apps fighting each other for the system resource and OS can kill our app anytime App…
Coroutines are similar to threads. Switching decision of the Coroutines are designed in the programming language and the programmer controls when the switch happens whereas switching of the threads are designed in the kernel level by some scheduling algorithm Coroutines never run in parallel or take advantage of multiprocessors whereas threads run parallelly and make use of processors Threads…
A routine is just a sequence of operations/actions which gets executed one by one in the exact same order as specified. Co stands for cooperation. A co routine suspend its execution to give other co-routines a chance to execute. So a co-routine is about sharing CPU resources so others can use the same resource. A coroutine is an instance of suspendable computation. coroutine is not bound to any…
I still remember some of the good old days when there was a daily power cut for about 1-2 hours. Especially in the evenings. No electricity means no TV, lights, or any other digital devices. Which basically meant we had to leave whatever we were doing and just sit there with the candlelight. It was one of those times where I just sat there without any distractions and my mind used to wander to the…
This image was taken on one fine evening when I was standing outside my house and I had the whole evening to me with nothing to do. Oh, what a great feeling it is to have plenty of free time with you and there is nothing stressfull to occupy your mind and spoil the moment. We all should savor these moments and appreciate the mindfullness it brings. Free time was the most precious time, when you…
Most of them get their daily dose of news online nowadays. IMHO reading news from the internet is more of a distraction and filled with personal opinions rather than the actual news. I always prefer reading the news in the newspaper. No bullshit, no drama, pure news. Most importantly, there is no rabbit hole to fall into in newspapers, unlike the internet where there are thousands of…
Always leave room for the unexpected. A buffer of time, a little extra money, a reserve of goodwill. You won’t be maximising every opportunity or squeezing out every last dollar, but what you lose in reward, you gain in safety. Survival is the highest return of all.
If you have developed an Android app you must have known these three attributes which are compulsory for any Android project. But, what are those? How does this matter for our app? Let’s understand this. minSDKVersion: This is an easy one. As the name says, it indicates the minimum SDK version on which the app will run. For example, if minSDKVersion is set to 21 (Android Lollipop) then the app…
Everyone in this world wants to become extraordinary. Everyone wants to make a dent in the world. People see multi-billionaire businessmen and rave about becoming one, people want to become a scientist and change the world with their invention, they want to get into Google, Facebook, to make an impact and look down upon someone who works in a small but healthy company. The problem with most of…
Yes, conditional statements are considered code smell if they are used extensively all over the project. alrighty, let us jump straight to the example to understand why . let’s assume we are making a network request to different news sources to get the top headlines from each source. fun getHeadlines ( source : String ) { when ( source ) { "BBC" -> fetchNewsFromBBC () "CNN" -> fetchNewsFromCNN ()…
Functional programming is a programming paradigm where programs are constructed using few principles. Let’s see what those principles are and how it is better than the regular oop. Declarative Focus on what rather than how, we have seen functions like filter , map , forEach . These methods focus on what it does rather then how it does the operation. Pure functions Function which always gives the…
Let’s just first get the basic definition of these 2 patterns clear. Dependency Injection: Dependency injection is nothing but injecting the dependencies to the class needed. Giving the class all of its dependencies somehow so that the class which requires those dependencies does not have to worry about those. Here’s the Wikipedia definition for Dependency injection In software engineering,…
Tell don’t ask principle says that Instead of asking an instance of class for data and acting on that data, we should tell an instance of class what needs to be done. Data and operations that depend on that data belong in the same object. Let’s look at some example Ask version Class EmailValidator ( private val user : User ) { // Let's just assume for the sake of this example that once the email…
Even your dream job sucks sometimes. Even the love of your life gets on your nerves sometimes. There is nowhere you “should be by now.” All life paths are different and equally valid. Happiness is a practice. It isn’t something you achieve and then you’re good.
This is the wikipedia definition for command query separation principle It states that every method should either be a command that performs an action, or a query that returns data to the caller, but not both. In other words, Asking a question should not change the answer. CQS basically says that your function name should exactly say what it does. For example consider the below code fun fetchNames…
Starting an android project from scratch requires quite a bit of boilerplate setup which involves getting all the dependencies which are up to date which itself is quite a bit of effort in itself which might take hours to do it in a correct way. Here are some of the pain points when starting new android project from scratch Dependencies: Getting all the dependencies which are up to date itself is…
When classes become quite large (Always try to have a class with less than 200 lines :) ), it becomes hard to focus on certain piece of logic without all the noise/distraction from other code present in the same file. To solve this we can use what is called as Regions in Android studio. Regions As the name says it basically helps in creating regions in android studio. We can have regions for click…
Have you ever ran a large number of tests in a file where few of them fails and you just wanted to rerun the failed test cases again?. Well Android Studio has this small icon right below the run icon which reruns the failed tests. Screenshot will explain much better That’s it for now. Hit me up on twitter if you have any cool tips that you want to share.
Most of us might have faced the problem of losing the scroll position of the RecyclerView when your Activity/Fragment is recreated. This usually happens because the Adapter data is loaded asynchronously and data hasn’t loaded by the time RecyclerView needs to layout so it fails to restore the scroll position. Restoring the scroll position using onRestoreInstanceState RecyclerView already has a…