Book Image

Android Design Patterns and Best Practice

By : Kyle Mew
Book Image

Android Design Patterns and Best Practice

By: Kyle Mew

Overview of this book

Are you an Android developer with some experience under your belt? Are you wondering how the experts create efficient and good-looking apps? Then your wait will end with this book! We will teach you about different Android development patterns that will enable you to write clean code and make your app stand out from the crowd. The book starts by introducing the Android development environment and exploring the support libraries. You will gradually explore the different design and layout patterns and get to know the best practices of how to use them together. Then you’ll then develop an application that will help you grasp activities, services, and broadcasts and their roles in Android development. Moving on, you will add user-detecting classes and APIs such as gesture detection, touch screen listeners, and sensors to your app. You will also learn to adapt your app to run on tablets and other devices and platforms, including Android Wear, auto, and TV. Finally, you will see how to connect your app to social media and explore deployment patterns as well as the best publishing and monetizing practices. The book will start by introducing the Android development environment and exploring the support libraries. You will gradually explore the different Design and layout patterns and learn the best practices on how to use them together. You will then develop an application that will help you grasp Activities, Services and Broadcasts and their roles in Android development. Moving on, you will add user detecting classes and APIs such as at gesture detection, touch screen listeners and sensors to our app. You will also learn to adapt your app to run on tablets and other devices and platforms, including Android Wear, Auto, and TV. Finally, you will learn to connect your app to social media and explore deployment patterns and best publishing and monetizing practices.
Table of Contents (20 chapters)
Android Design Patterns and Best Practice
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

How this book works


The purpose of this book is to show how the application of design patterns can directly assist the development of Android applications. During the course of the book we will be concentrating on the development of a complete client-side mobile application, focusing particularly on when, why, and how patterns can and should be employed during Android development.

Historically, there has been a certain amount of disagreement as to what exactly constitutes a pattern. However, the 23 patterns laid out in the 1994 book Design Patterns by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, the so-called gang of four, are widely accepted as the definitive set and provide solutions to nearly all of the software engineering problems that we are likely to encounter, and it is for this reason that these patterns will form the backbone of the book. These patterns can be broken down into three categories:

  • Creational - Used for creating objects

  • Structural - Used for organizing groups of objects

  • Behavioral - Used for communication between objects

The practical nature of this book means that we will not be tackling these categories in the order they appear here; instead, we will explore individual patterns as and when they arise naturally during the development of our app, although this generally means starting with creating a structure first.

It would be difficult, clumsy, and unrealistic to incorporate all design patterns into a single application, so here will attempt to apply as many as might seem realistic. For those patterns we decide not to use directly, we will at least explore how we might have done so, and in every case give at least one practical example of how they are used.

Patterns are not written in stone, nor do they solve every possible problem, and towards the end of the book we will look at how, once we have a grasp of the subject, we can create our own patterns or adapt extant ones to suit the rare circumstances where none of the established patterns fit.

In short, patterns are not a set of rules but rather a series of well-worn paths leading from known problems to tested solutions. If you spot a shortcut along the way, then by all means use it. If you stick to it consistently, then you will have created a pattern of your own that is just as valid as the traditional ones that we will cover here.

The first few chapters of the book concentrate on UI design and introduce a few essential design patterns and how they work conceptually. From about Chapter 6, Activating Patterns, onward, we will start to apply these and other patterns to real-world examples, and to one application in particular. The final chapters concentrate on the final stages of development, such as adapting applications for differing devices, a task almost purpose-built for design patterns, reaching the widest possible market and how to monetize our apps.

Note

In case you are new to Android development, the instructions laid out in the first two or three chapters are given in detail. If you are already familiar with Android development, you will be able to skip these sections and concentrate on the patterns themselves.

Before we get stuck into our first patterns, it makes sense to take a closer look at the app we will be building during the course of the book, as well as the challenges and opportunities it presents.