Understanding MVVM on Android Tutorial 02 – Defining the Model with GSON and POJOs

Over the course of this series, we’ll be building an app that uses RESTful APIs to fetch data in JSON format and display it in our app. A good place to start (…in any development project) is to define the model layer. What is the business domain for the app? What high level objects can be used to represent the business domain? And what are the relationships between the various business objects? As an example, if we were defining the model for a school administration system, a first attempt at defining the model may produce the following objects: Student, Course, and Staff. In our case, we will be building a “GitHub Repo Reader” app that fetches and displays all the repositories of a single github user.

Continue reading…

Understanding MVVM on Android Tutorial 01 – MVC vs MVP vs MVVM

As an android developer, you may have been asked by an employer/client to implement an architecture pattern when developing your app. Examples of commonly used patterns are MVC, MVP and MVVM, with most Android developers choosing either the MVP or MVVM pattern. However, there is a lot of discrepancy and confusion on how to implement these patterns “correctly” and I know a lot of developers have been struggling with the MVVM pattern due to so many contradictory or confusing approaches. This post is my attempt to demonstrate a “really simple” but detailed step-by-step demonstration of using the MVVM pattern in an Android app. Through the course of the series, we will be developing an app which accesses a REST API and displays the received data in the app. We will also be making using of some popular Android libraries like GSON, Retrofit2, RXJava and Dagger2.

What is a software architecture pattern anyway? Continue reading…