My fourth sprint was largely centered around learning and using design patterns. When you're writing an Android app it's important to utilize design patterns to make the code more readable, maintainable, and reusable. A software design pattern is a solution to a commonly occurring problem within a given context that can be used in many different situations. There are many different types of patterns, two types I used to develop the Fitness Explorer app are creational, architectural, and structural.

Factories & Creational Patterns

A creational pattern is a pattern that is used to deal with object creation mechanisms in a way that is suited for the situation. A factory is a creational pattern, therefore it deals directly with object creation. The most useful thing about the factory method pattern is that you don't have to specify the exact class of the object that will be created. This is useful so that you're not repeating the same code in many different places. I utilized two factories I created for my app including the RepositoryFactory, which returns a new GoogleFitRepostory, and a RandomColorFactory, which returns an ActivityColor which is a combination of a string representation of an activity with its integer representation of a color.

Architectural Patterns & the Android MVC

An architectural pattern is a concept that solves and delineates some essential cohesive elements of a software architecture. In other words it solves a common architectural problem by virtue of following its pattern. The architectural pattern I used for the Fitness Explorer app is the Android MVC, which utilizes Activities and Fragments to display the interface to the user. The architecture I used for the Fitness Explorer app maps the Activity to the controller and the Fragment to the view.

Translators & Structural Patterns

Structural patterns are incredibly useful because they ease software design by identifying a simple way to construct a relationship between entities. This allows for less code duplication and increases the overall readability of the code tremendously. I used a translator for the decoding of returned information from Google Fit. I first created an interface to define the methods I'm going to need.

From here I created the GoogleFitEntityTranslator class. This was a very helpful addition to my app because I needed to have similar code in many different places in the Google Fit Repository.

Next Sprint

The next sprint will focus on some of the most practical elements of building my app. I'll take a look at prototyping my app, and connecting to the Google Fit API.