Androidx Kotlin App – MVVM + Dagger2 + RxJava + Retrofit + Butterknife + Mockito + UnitTest + Robolectric + MockWebServer

Steps:1. Configure gradle with libs dependencies2. Create model classes3. Create repository module4. Create ViewModel for City5. Create DI (dependency injection) module6. Create Unit test7. Create UI8. Update Application, DI modules Let’s start:1. Configure gradle with libs dependencies – 2. Create model classes –I am using Open Weather Map http://api.openweathermap.org/data/2.5/weather?q=London,uk ‘s City weather api to demonstrateContinue reading “Androidx Kotlin App – MVVM + Dagger2 + RxJava + Retrofit + Butterknife + Mockito + UnitTest + Robolectric + MockWebServer”

Beginner’s guide – Some Design patterns which are must for developers

A good developer needs to learn following things –1) SOLID 2) Abstract factory pattern3) Factory method4) Singleton pattern5) Builder pattern6) Observer pattern7) Template pattern Abstract Factory pattern – (Families of Objects) When to use? – “When you have families of objects to create for certain variants” Like ? – 1) Chair, Table, Sofa for –Continue reading “Beginner’s guide – Some Design patterns which are must for developers”

How Framework’s entry point written? in C++ window application.

Writing your own Framework/Toolkit – During my MFC days, I use to wondering how my application works without main() function? Then deep drive into CWinApp code I found WinMain(). During NCST-PCCP project which was on “User defined inteface library” where we had written toolkit library like Java awt, in C++ with NCurses. We tried toContinue reading “How Framework’s entry point written? in C++ window application.”

Unit testing by mocking static method of ActivityCompat – Android for permission

Usually while writing unit tests for our code is easier with mocking the stubs, but when we need to mock the third party code or specially OS classes it becomes very tough or sometimes impossible. One of such class is ActivityCompact which has static functions only. Mocking static function is something not advisable and sometimesContinue reading “Unit testing by mocking static method of ActivityCompat – Android for permission”

Pascal Triangle – using single dimension array

I wrote this code to print pascal triangle using single dimension array, I think interviewer thought it can be done in 2D only.. public class HelloWorld{      public static void main(String []args){         print(6);      }      public static void print(int n){          int size =Continue reading “Pascal Triangle – using single dimension array”