Clean Android Architecture - Alexandru Dumbravan - E-Book

Clean Android Architecture E-Book

Alexandru Dumbravan

0,0
28,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

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.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 318

Veröffentlichungsjahr: 2022

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Clean Android Architecture

Take a layered approach to writing clean, testable, and decoupled Android applications

Alexandru Dumbravan

BIRMINGHAM—MUMBAI

Clean Android Architecture

Copyright © 2022 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Rohit Rajkumar

Publishing Product Manager: Nitin Nainani

Senior Editor: Aamir Ahmed

Content Development Editor: Feza Shaikh

Technical Editor: Simran Udasi

Copy Editor: Safis Editing

Project Coordinator: Manthan Patel

Proofreader: Safis Editing

Indexer: Rekha Nair

Production Designer: Shyam Sundar Korumilli

Marketing Coordinator: Teny Thomas

First published: June 2022

Production reference: 2280922

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-80323-458-8

www.packt.com

This book is dedicated to all the developers who went the extra mile to learn, practice, hack, innovate, and then pass their knowledge on to others. This propelled our development world forward and made this book a possibility. This book is also dedicated to all the people in my life who supported me through the times I was staring desperately at a computer screen filled with compile errors.

Alexandru Dumbravan

Foreword

“If you think good architecture is expensive, try bad architecture.”

— Brian Foote, CEO of HUMBL

We know deep down that this statement is true. Poorly architected code can cause problems in your application, but it can also make your code hard to understand, navigate, be improved upon, and difficult to use for other developers.

“The glass is neither half empty nor half full. It’s simply larger than it needs to be.”

— Grace Hopper

Grace Hopper was an American computer scientist and Navy officer. She knew the importance of a well-structured and clean architecture. They’re flexible, higher performing, far more scalable, easier to test, and you can maintain them a lot faster and more easily. A clean architecture is focused on getting the application layers built as efficiently as possible, without leaving behind (as Grace might say) leftover cup.

In a mobile application, clean architecture is more important than ever. You might find yourself battling against battery issues, memory consumption issues, security problems, compatibility, or environmental changes. Your mobile application needs to truly achieve portability.

In Clean Android Architecture, Alexandru Dumbravan applies his experience of developing Android applications for over 10 years. He takes you through a quick tour of the core software design principles and through the key features in the Android framework and supporting libraries.

Next, you’ll dig deep in data sources. It’s vital to understand the libraries and frameworks that are available for you to access and manage data. Then, Alexandru naturally transitions into data presentation. How do you present data to the user? You’ll break down how the user interface (UI) works and how to build your own UI solution.

Later, you’ll learn how to manage dependencies. Part of the value that Alexandru brings to the book is that he shows you how these different challenges were handled in the past, and what has changed over time. You’ll then see how to build the domain layer to sit in the center of your application and to control your app logic. Next, you’ll build the data layer to create and manage your data. The presentation layer handles the UI and the input/output. Finally, you’ll put the modules together and test your application.

By building an Android application with a clean architecture, you’ll be able to put every piece of your code to work, and you’ll end up with a far more scalable, performant, and maintainable application. This is a book that you’ll want to come back to, to make sure you’ve got each step of this process down. And once you do, well, we all know that the present and future is in mobile applications. So, the question is, where are you taking us?

Ed Price Senior Program Manager of Architectural Publishing Microsoft, Azure Architecture Center (http://aka.ms/Architecture)Co-Author of 7 Books, including Meg the Mechanical Engineer, The Azure Cloud Native Architecture Mapbook (Packt), and ASP.NET Core 5 for Beginners (Packt)

Contributors

About the author

Alexandru Dumbravan has been an Android developer since 2011 and has worked across a variety of Android applications that have contained features such as messaging, voice calls, file management, and file management. He continues to broaden his development skills while working in London for a popular fintech company.

About the reviewers

Revathi Gopalakrishnan is a software professional with 20 years of experience in the IT industry. She has worked extensively in mobile application development and has led various enterprise mobile enablement initiatives for large organizations and consumer applications for customers around the globe. She is also interested in emerging areas, such as machine learning, IoT, and robotic process automation. She has authored a book with Packt titled Mobile Machine Learning. Revathi resides in Chennai and enjoys spending her weekends with her husband and her two lovely daughters.

Jose Miguel is a software engineer who specializes in mobile development, with 5 years of experience. He has an Android associate developer certification from Google. He is also involved in the start-up tech community as a mentor in the OpenLab Peru community, bringing guidance to new Android developers and entrepreneurs who want to gain certain expertise in the mobile world. He resides in Lima, Peru, and enjoys watching movies, reading comics, boxing, traveling, and learning about new cultures and people around the world.

Table of Contents

Preface

Part 1 – Introduction

Chapter 1: Getting Started with Clean Architecture

Technical requirements

The architecture of a legacy app

Legacy analysis

Software design principles

SOLID principles

Component cohesion principles

Component coupling principles

Exploring the evolution of Android

Fragments

The Gradle build system

Networking

Humble objects

Functional paradigms

Kotlin adoption

Dependency injection

Android architecture components

Coroutines and flows

Jetpack Compose

Enter clean architecture

Summary

Chapter 2: Deep Diving into Data Sources

Technical requirements

Understanding Kotlin coroutines and Flows

Kotlin coroutines

Exercise 02.01 – Using Kotlin coroutines

Kotlin Flows

Exercise 02.02 – Using Kotlin Flows

Using OkHttp and Retrofit for networking

Exercise 02.03 – Using OkHttp and Retrofit

Using the Room library for data persistence

Exercise 02.04 – Using Room to persist data

Understanding and using the DataStore library

Exercise 02.05 – Using DataStore to persist data

Summary

Chapter 3: Understanding Data Presentation on Android

Technical requirements

Analyzing lifecycle-aware components

Exercise 3.1 – Using ViewModel and LiveData

Using Jetpack Compose to build UIs

Exercise 3.2 – Navigating using Jetpack Compose

Summary

Chapter 4: Managing Dependencies in Android Applications

Technical requirements

Introduction to DI

Using Dagger 2 to manage dependencies

Using Hilt to manage dependencies

Exercise 04.01 – Using Hilt to manage dependencies

Summary

Part 2 – Domain and Data Layers

Chapter 5: Building the Domain of an Android Application

Technical requirements

Introducing the app's architecture

Creating the domain layer

Exercise 05.01 – Building a domain layer

Summary

Chapter 6: Assembling a Repository

Technical requirements

Creating the data layer

Creating repositories

Exercise 06.01 – Creating repositories

Summary

Chapter 7: Building Data Sources

Technical requirements

Building and using remote data sources

Exercise 07.01 – Building a remote data source

Building and integrating local data sources

Exercise 07.02 – Building a local data source

Summary

Part 3 – Presentation Layer

Chapter 8: Implementing an MVVM Architecture

Technical requirements

Presenting data in Android applications

Presenting data with MVVM

Exercise 08.01 – Implementing MVVM

Presenting data in multiple modules

Exercise 08.02 – Multi-module data presentation

Summary

Chapter 9: Implementing an MVI Architecture

Technical requirements

Introducing MVI

Implementing MVI with Kotlin flows

Exercise 09.01 – Transitioning to MVI

Summary

Chapter 10: Putting It All Together

Technical requirements

Inspecting module dependencies

Exercise 10.01 – Reduce dependencies

Instrumentation testing

Exercise 10.02 – Instrumented testing

Summary

Other Books You May Enjoy

Part 1 – Introduction

In this part, you will become familiar with the notion of clean architecture and the principles it provides. This part also explores the tools, frameworks, and libraries used later in the book. 

This part includes the following chapters:

Chapter 1, Getting Started with Clean ArchitectureChapter 2, Deep Diving into Data SourcesChapter 3, Understanding Data Presentation on AndroidChapter 4, Managing Dependencies in Android Applications