Book Image

Clean Android Architecture

By : Alexandru Dumbravan
Book Image

Clean Android Architecture

By: Alexandru Dumbravan

Overview of this book

As an application’s code base increases, it becomes harder for developers to maintain existing features and introduce new ones. In this clean architecture book, you'll learn to identify when and how this problem emerges and how to structure your code to overcome it. The book starts by explaining clean architecture principles and Android architecture components and then explores the tools, frameworks, and libraries involved. You’ll learn how to structure your application in the data and domain layers, the technologies that go in each layer, and the role that each layer plays in keeping your application clean. You’ll understand how to arrange the code into these two layers and the components involved in assembling them. Finally, you'll cover the presentation layer and the patterns that can be applied to have a decoupled and testable code base. By the end of this architecture book, you'll be able to build an application following clean architecture principles and have the knowledge you need to maintain and test the application easily.
Table of Contents (15 chapters)
Part 1 – Introduction
Part 2 – Domain and Data Layers
Part 3 – Presentation Layer

Presenting data in Android applications

In this section, we will look at various architecture patterns suitable for presenting data in an Android application and analyze their benefits and drawbacks.

Early Android applications relied on a pattern similar to the Model-View-Controller (MVC) architecture pattern, where an activity is the Controller, the View is represented by the android.widget.View hierarchy, and the Model is responsible for managing the application's data. The relationship between the components would look something like the following:

Figure 8.1 – Android MVC relationship

From Figure 8.1, we can see that the Controller represented by the activity would interact with the Model to fetch and manipulate the data, and then it would update the View with the relevant information.

The idea is to have each Activity sandboxed as much as possible so that they can be offered and shared between multiple applications (like how the Camera...