Humble Views, Proud ViewModels

The Android Community has long advocated that Activities and Fragments were views - but this perception has changed over time. For good. Let’s dive deep into how to design views and view models, how they wire to a LifecycleOwner, and how this can positively impact your’s app testability. To better describe how to build humble views we will be developing an elementary Sign-Up form with an email, a password text field and two buttons: a cancel that pops the user’s back stack and a sign up that creates an account and moves the user to the home screen....

February 1, 2021

Naming Factory Methods

When discussing Factory Methods, extension functions are often preferred in Kotlin. However, naming these functions in a discoverable way without cluttering your project’s namespace can be challenging. A great source of inspiration is Kotlin’s Standard Library, which offers numerous examples to guide function design. Wrapping an Instance If you want to take an existing instance and adapt it to a different object to meet another contract—such as creating a ViewModelProvider.Factory that internally uses a javax....

February 1, 2020