We have seen how patterns can help us organize our code and how this can be applied specifically to Android apps, but we have only applied one pattern at a time. As the tasks we need to perform become more complex, we will need to apply several patterns, such as decorators and builders, at once and even combine them into hybrid patterns, and this is what we will do in this chapter.
We will begin by considering a more complex user interface (UI) and the code behind it. This will require us to think a little more precisely about what we actually want our application to do. This in turn will lead us to look at the prototype pattern, which provides a very efficient method for creating objects from an original, clone, object.
The decorator pattern is explored next, and we see how it can be used to add extra functionality to existing classes. Often referred to as a wrapper, the decorator is used to provide additional functionality to existing code. This is particularly...