Book Image

Expert Android Programming

Book Image

Expert Android Programming

Overview of this book

Android O brings a number of important changes for the users as well as the developers. If you want to create smart android applications which are fast, lightweight and also highly efficient then this is the book that will solve all your problems. You will create a complex enterprise grade app in this book. You will get a quick refresher of the latest android SDK and how to configure your development environment. Then you will move onto creating app layouts, component and module building, creating smart and efficient UIs. The most important part of a modern day app is how real time they are. With this book, you will create a smooth back-end for your app, ensure dynamic and real time communication between different app layers. As we move on, you will learn to leverage the different Android APIs and create an efficient SQLite data layer for your apps. You will implement effective testing techniques to make your app reliable and robust and finally you will learn to deploy it efficiently. The multiple stages of android development will also be simplified by giving you an industry standard set of best practices.
Table of Contents (17 chapters)
10
Building Restaurant finder

Open-Closed Principle

The Open-Closed Principle states that:

Software entities (classes, modules, functions, etc) should be open for extension, but closed for modification.

This principle basically states that we have to design our modules, classes, and functions in a way that when a new functionality is needed, we should not modify our existing code but rather write new code that will be used by existing code

Now let us discuss the Open-Closed Principle in the following example.

Let us assume we are trying to calculate the area of some shapes. So let's take the example of a rectangle and a circle. The classes for these have been formed in the following code:

public class Rectangle { 
   private double length; 
   private double height; 
   // getters/setters ... 
} 
 
public class Circle { 
   private double radius; 
   // getters/setters ... 
} 

So a common function used...