Android Design Patterns and Best Practice
Copyright 2016 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, and its dealers and distributors will be held liable for any damages caused or alleged to be 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.
First published: December 2016
Production reference: 1201216
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78646-721-8
www.packtpub.com
Credits
Author Kyle Mew | Copy Editor Safis Editing |
Reviewer Vctor Albertos | Project Coordinator Devanshi Doshi |
Commissioning Editor Amarabha Banerjee | Proofreader Safis Editing |
Acquisition Editor Shweta Pant | Indexer Mariammal Chettiyar |
ContentDevelopmentEditor Narendrakumar Tripathi | Graphics Jason Monteiro |
Technical Editor Anushree Arun Tendulkar | Production Coordinator Shantanu N. Zagade |
About the Author
Kyle Mew has been programming since the early eighties and has written for several technology websites. He has also written three radio plays and three other books on Android development.
About the Reviewer
Victor Albertos has been developing Android apps for 5 years. During this time, he had the chance to explore several approaches to achieve maintainable and testable code. From an imperative style, gradually he has switch to a more declarative one, applying concepts and theories from functional languages such as Haskell to the Android and Java ecosystem.
He is an active open source contributor, sharing with the Android community useful libraries, mainly focused on reactive programming.
Currently he is working as an Android architect at Sabadell Bank.
I would like to thank to my family for their constant support, my few friends for being always there, and specially to Inma, who I deeply love.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Why subscribe?
- Fully searchable across every book published by Packt
- Copy and paste, print, and bookmark content
- On demand and accessible via a web browser
Customer Feedback
Thank you for purchasing this Packt book. We take our commitment to improving our content and products to meet your needs seriouslythat's why your feedback is so valuable. Whatever your feelings about your purchase, please consider leaving a review on this book's Amazon page. Not only will this help us, more importantly it will also help others in the community to make an informed decision about the resources that they invest in to learn.
You can also review for us on a regular basis by joining our reviewers' club. If you're interested in joining, or would like to learn more about the benefits we offer, please contact us : customerreviews@packtpub.com
Preface
Welcome to Android Design Patterns and Best Practice , a comprehensive guide to how to get the most out of your apps with the tried and tested programming philosophy, design patterns. These patterns provide a logical and elegant approach to solving many of the development problems that coders face. These patterns act as a guide creating a clear path from problem to solution, and although applying a design pattern does not guarantee best practice in itself, it will hugely assist the process and make the discovery of design flaws far easier.Design patterns can be implemented on very many platforms and written in as many programming languages. Some code libraries even apply patterns as part of their internal mechanics, and many readers will already be familiar with the Java Observer and Observable classes. The Android SDK we will be exploring makes great use of many patterns, such as factories, builders and listeners (which are really just observer patterns). Although we will cover these built-in design patterns, the book will mostly explore how we can build our own, custom made, patterns and apply them to Android development.Rather than approach each design pattern in turn, this book approaches the subject from the perspective of a developer, moving through each aspect of app development exploring individual design patterns as they would arise in the course of building an Android app. To clarify this journey, we will be focusing on a single imaginary app, designed to support a small business. This will take us from application conception through to publication, covering such topics as UI design, internal logic and user interaction along the way. During each of these steps we will explore those design patterns that are relevant to that process, by first exploring the pattern in its abstract form and then applying it to that particular situation.By the end of the book you will have learned how design patterns can be applied to all aspects of Android development and how using them assists best practice. It is the concept of design patterns that is more important than any specific pattern itself. Patterns can, and should, be adapted to suit our specific purposes, and by learning this way of approaching app development, we can even go on to create entirely original patterns of our own.
What this book covers
, Design Patterns , introduces the development environment, and two common design patterns, the factory and abstract factory.