5 Tips to Scale Your Android Development

by: | Feb 3, 2015

Whether you work at a small startup or a large company, you probably face the challenge of how to scale — most likely in several facets of your business. For us, it’s how to scale Android development team to accelerate our clients’ time to market.

Scaling is an often used term. But it comes down to simple terms: Scaling is growth, and growth is revenue.

As an Android developer, I’ve been thinking a lot about how to continually scale Android development practices so that our clients get the most value from our time — and so our code is more consistently clean and less likely to hide bugs. While there is no perfect solution to scale your development teams, there are common standards that can greatly help you along the way.

1. Separate responsibilities and keep things modular.

Objects and classes are designed to perform certain tasks — try to keep them focused on only doing those tasks they were made for. For example, don’t try and perform network tasks in a Datastore class, and vice versa. The more you can separate your logic, the easier it will be to update individual classes later. A good general rule of thumb is to keep your method sizes less than rougly 40 to 50 lines, and your classes less than a few hundred lines.

2. Implement a consistent code formatter.

On Android Studio, you can set up your preferred format style under Preferences/Code Style/Java. Once you have a custom template, you can export it and share it across your team. Then any team member can apply it to a project, and it will automatically rearrange your code. This can save hours of time by improving readability. It also guarantees consistency when team members dive into an area of the code that is new to them — and can simplify the code review process by ensuring the only diffs (differences) are intentional. This scheme should be placed in the ~/Library/Preferences/AndroidStudio/codestyles folder on Mac. Bonus tip: Set up a macro so that whenever you press save, it also runs a format.

3. Test your code throughout your Android development project — not just after.

Adding unit tests is a step toward implementing a test-driven development strategy (TDD), and is an absolute necessity for making sure your code is performing the way you expect. For example, in a Datastore class, there might exist a method storeMyValue(). A range of unit tests could be written to ensure that for various ranges of data — expected and unexpected — and through each branch of the method, it does indeed store “myValue”.  There’s a lot of great information about unit testing here on Google’s Android Developer site.

4. Add automated code checking for best practices.

There are several tools available to scan your code and make sure that you are following decades of the industry’s best practices. The most common ones are FindBugs, PMD, and Checkstyle. Here is an example from my GitHub repo of how you can implement Checkstyle, FindBugs, and PMD checks in your app.

5. Go with an MVP approach for Android development.

Not to be confused with the “Minimum Viable Product,” our approach to lean app development, using an MVP method in development means separating the Model, View, and Presenter within your code. This is similar to the MVC pattern highly talked about on iOS. The basic idea is that the View layer should never ask the Model layer directly — because that’s what the Presenter is for. By separating the presentation layer from the logic, how you layout the data on screen becomes modularized and separated from how you pull the data from a server or a database. This style lends itself to higher readability, easier testing, and more seamless collaboration overall.

Thinking about your next mobile app?

Whether you’re scaling your company’s Android capabilities or working on a new cross-platform mobile app, ArcTouch can help. Contact us for a free consultation.