One upon a time, there was a singularity named :app module. Then came the smaller monoliths, namely :persistence, :networking and :models

Image for post
Image for post
Photo by Clay Banks on Unsplash

Why layers monoliths is a mistake?

  • All the problem that applies to :app still applies to :networking , :persistence and :models while you get none of the benefits modularization brings

Why is it the greatest mistake?


Image for post
Image for post
Photo by Ed Leszczynskl on Unsplash

Problem

Even though Proguard and R8 removed the unused code for you at release time, you should still make effort to remove dead code to reduce confusion, increase productivity of your everyday work and onboarding.

Solution

For starter, none of the static code analysis tools (SonarQube, CheckStyle, Pmd, Findbugs, Android Lint) I know does the job.

Since Proguard and R8 removed unused classes, I followed the instructions here and generated and generated an usage.txt file

  • Add -printusage to your proguard.pro file
  • Run ./gradlew app:minifyReleaseWithProguard or ./gradlew app:minifyReleaseWithR8

But the usage.txt file is big and I can clearly see some classed that are used, not dead code. …


Image for post
Image for post
Photo by Tierra Mallorca on Unsplash

Imagine you went to meet your Tinder date and were informed on the spot that John or Mary or both were gonna join you presently. Replace Tinder date with your credit card application and and voila! Equifax and TransUnion are gonna enter your life and never leaves, forever ruining your relationships in a creepy way

Surprise surprise!

My first bank account in Canada was frozen out of the blue in June 2020. For more than 3 months, I had never been offered anything more than “one of the credit bureaus put a restriction on your files”.

Mistrust and verify

My credit started at below 650 which means Poor credit. Which means none of the following means…


Image for post
Image for post

Given a list of Employees, find the average and sum of salary for each department.

You don’t have to be a Kotlin-programmer or any programmer to complete the following 4 tasks, just a curious mind and a love for numbers will do

Each Employee has the following properties:

  • Name
  • Department
  • Salary
  • Title

Does that sound familiar? I’m sure it does to all of us who have been through the 101 tutorial for Excel and SQL.

Buckled up as today we are going to learn how to achieve the same tasks with Kotlin aka.


Recently, when doing a small coding challenge in Kotlin I was faced with the choice of mutableMapOf() or HashMap()

Image for post
Image for post
Photo by Marc Sendra Martorell on Unsplash

Being a Java old-timer, I went with HashMap() .

But but… all the Kotlin tutorials start with mapOf() and mutableMapOf() ?

Afterwards, I had some interesting discovery to share here:

Behind the scene, both mapOf and mutableMapOf use Java’s LinkedHashMap data structure

Utimately, the comparison between mapOf, mutableMapOf() and HashMap() is down to LinkedHashMap vs. HashMap in Java.

These are the 2 most popular implementations of Map (or Dictionary or Hashtable if you will) data structure in Java. …


There’s no one-size-fit-all solution here but Tangerine is a good start

Image for post
Image for post

Why online-only banks?

Convenience

The time and money you spend on your trips to the bank branch can be spent on something else valuable.

Remember those times you went there only to realize the branch is closed or you left an important document at home?

No more!

Remarkedly, I moved to Canada just before the Covid-19 pandemic causing all brick and mortar banks to close. Tangerine (and Canada Post of couse) saved me this time!

Better rates and lower or no fees

Future proof

As online-only banks saves a lot of costs from operating physical branches, they can invest more in innovations, thus improve their service quality. …


After struggling to set up Dagger from scratch N times, this article will make the (N+1)th time much easier, hopefully.

What is dependency injection first of all?

As explained by Dan Lew, it simply means passing dependencies through your class’s constructors or functions’ parameters so as to be able to swap them in unit tests.

(MVP is used for simplicity here. Same concepts apply to MVVM)

Here’s a very basic testable Presenter that make use of dependency injection:

Why Dagger?

  1. Cleaner code due to dependencies separated from Activity/ Fragment code
  2. Avoid memory leaks — free up resources according to life-cycle events (We do have to explicitly couple the dependencies with an Android component such as an Activity. It’s called “Dagger Scope” annotations and there are many articles on this the Internet. …


We’ve covered the output streams (ViewState and ActionState) in part 1

Image for post
Image for post
ViewModel’s input and output streams

Quick recap of the output streams in part 1:

  • MVVM leverages Observer pattern in which the ViewModel is the Subject while the View is the Observer
  • But the View can have multiple Observers. I proposed a) ViewState Observer for UI updates like setting TextView’s text and b) ActionState Observer for events like “log out of all devices”

In this part, I’m omitting the ActionState Observer, as the ViewState Observer alone is sufficient to demonstrate the “good practice” I want to introduce here.

The challenge

Now after initialisation, there are important events with important data that need to be processed like onActivityResult , __Swipe to Refresh__. Only the View (Activity/ Fragment) receives them so it’s supposed to relay them to the ViewModel. …

About

Eric N

Hiring Android engineer shorturl.at/bivJO Clean coder, walker & biker. Hater of inefficiency

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