In Advanced Android App Architectures, you’ll find a diverse and hands-on approach to architecting your apps on Android. Android development can be fun; however, scaling an app can have its fair share of problems.
In this book, you’ll learn why a conversation on architecture is the first important step to taking your app to the next level!
This book will introduce you to a number of architectures, including Model View Controller, Model View Presenter, Model View Intent, Model-View-ViewModel and VIPER. You’ll learn theory, explore samples that you will refactor and learn the fundamentals of testing.
Before You Begin
This section tells you a few things you need to know before you get started, such as what you’ll need for hardware and software, where to find the project files for this book, and more.
This section introduces you to topics that will serve as a foundation for your understanding of the UI architecture patterns. You’ll get introduced to the sample project, an app named WeWatch, that allows users to keep track of movies to watch. You’ll also learn concepts that aid architecture, including Android Architecture Components and dependency injection.
This chapter explains what this book is about and its intended audience. By reading this chapter, you’ll gain a better understanding of why apps need good architecture. You’ll also get an introduction to the sample app that you’ll be building throughout this book.
The sample project starts off written in the Model View Controller pattern, with the Android Activity serving as both the View and the Controller. In this chapter, you’ll learn the history of the MVC pattern as applied to Android, and you’ll learn why this UI architecture pattern fails to meet two primary standards for good code: separation of concerns and unit testability.
In this chapter, you’ll get an overview of the Android Architecture Components and go into detail on the libraries used in the sample project at various points in the book: Room, ViewModel, LiveData and Data Binding.
An important concept in writing testable code is using dependency injection to inject mock objects into code. Here, you’ll learn the theory behind dependency injection and create a practical sample project using Dagger 2, a popular dependency injection framework for both Java and Android.
In this chapter, you’ll get an overview of RxJava and go into detail on how the library is used in the sample project at various points in the book.
Section II: Fundamental UI Architectures
In this section, you’ll rewrite WeWatch three different ways, first using MVP, then using MVVM with data binding, and finally using MVVM with Android Architecture Components. Though a user of the app won’t be able to see any difference after each of these changes, you as a developer will see how they solve some of the problems of the original WeWatch app written in MVC.
The first architecture pattern you’ll learn is Model View Presenter. Here, you’ll learn the theory behind pulling presentation logic out of the Android Activity and why it results in a significant improvement over the MVC pattern in terms of separation of concerns and testability of code.
The next architecture pattern you’ll learn is Model-View-ViewModel, a pattern which centers on exposing a stream of events to Views. Architecting your app this way helps you write loosely coupled and easily testable code.
Having completed the refactoring of the app to MVVM, you’ll write unit tests on the ViewModel to ensure it behaves as expected.
Section III: VIPER & MVI
In this section, you’ll rewrite WeWatch two different ways, first using VIPER and then using MVI. VIPER is similar to the MVP architecture but adds another two layers of abstraction to provide the highest level of modularity. On the other hand, MVI follows a different approach by using reactive programming principles with powerful libraries such as RxJava.
Now that you know how VIPER works, you’ll apply your new knowledge by rewriting WeWatch using this new pattern. You’ll also learn how to use Cicerone to create your Routers to navigate through the Views of your app.
MVI is a special architecture pattern that relies on reactive programming to react to user actions and render your Views. You’ll learn how to create Intents, Views and Models that represent a state of your app.
Vijay is a husband, father and senior mobile engineer. Based out of Canada's capital, Vijay has worked on dozens of apps for...
Who is this book for
This book is for intermediate Android developers who already know the basics of Android and Kotlin development but want to learn how best to organize code for scale.UI
development but want to learn coroutine API in order to simplify and optimise their code.
Concepts covered in this book
Model View Controller Theory
Android Architecture Components
Model View Presenter Theory
Model View ViewModel Theory
Model View Intent Theory
First Edition · Android 9, Kotlin 1.3, Android Studio 3.2
In Advanced Android App Architectures, you'll find a diverse and hands-on approach to architecting your apps on Android. Learn how to build scaleable and maintainable architectures in Android and Kotlin, including MVC, MVP, MVI, MVVM and VIPER!