Not too long ago, Java appeared to be on a downward trajectory, and many were ready to write it of as the next COBOL. But that didn’t happen – conversely, the language is riding high in any league you’d care to mention. Although pure Java on mobile remains very much a pipe dream, through the flourishing Android ecosystem, Java’s footprint has grown exponentially. Taking this as a starting point, RebelLabs has produced a report which hones in on Java on both sides of the Dalvik divide, zeroing in on what Android specialists can learn from core Java people, and vice versa.  Part of Java productivity people ZeroTurnaround, RebelLabs is naturally pretty savvy about this kind of thing, having launched a version of  Java tool ‘JRebel’ for Android earlier this year.

The big take home for developers coming from planet Java is that, when embarking on a mobile mission, you’re going to need to leave some backend habits at the door. On the flip side, there are a wealth of tools, libraries and patterns in the Java ecosystem which Android developers are failing to utilise, risking needless wheel reinvention.

And with the colossal fragmentation going on in Android (one company reports to the Rebels that over a few months in 2014, they saw “18,769 distinct devices” download their app), any streamlining is something to be embraced. This means that, even if developers just choose to focus on one version of Android (wiping out a spectrum of revenue streams in one fell swoop), they’ll still have a laundry list of choices to work through for each build.

Android SDK

Image: RebelLabs, “Android: the Platform, the Framework, and the Way of Life” zeroturnaround.com

It’s also important to take into account that fixing compatibility with older devices down the line is always more hassle than having it baked in from the outset. RebelLabs note that besides the plethora of mobile systems, there’s a growing coalition of Android “big-kid-toys” to work with, from tablets and cars to fridges. It’s up to you how far you’re willing to go in terms of heavy lifting to be at the very cutting edge, but it’s important to note that it all adds up rather quickly. The lesson here is to make your choice about which systems to support early on in the planning process, working out which ones you can most afford to ignore.

And on to the nitty gritty of development. Simon Maple comments, “One of the key takeaways of this report is to make sure your code respects the separation of responsibilities. This stops your business logic from being polluted by the Android layer. You might want to reuse some of your application components in a webapp at a later date, and you do not want it to be entangled with a specific UI layer. Similar decisions can be made designing your persistence code. Dependency Injection is key to the success of this separation, so consider using Dagger to help you achieve this.”

Maple also highlights the golden rule for parallelization in Android: stay off the main thread as much as you can, or risk heavy penalties when it comes to user response times. Developers should consider using managed concurrency framework AsyncTask to keep their work clear from this risky main thread, or consider an event bus model such as Otto framework.

Finally, when it comes to Android, given the huge array of  screen sizes and devices your app could potentially run on, the report writers emphasise that testing is your best friend – even if it might feel like a tortuously slow process. A good way for Android devs to do this is to adopt some of the tools from their Java brethren, which have already been ported to Android, including mocking. Mockito, JUnit, Spock, JBehave, Cucumber and various other frameworks and libraries.

For a deeper dive into the learnings of RebelLabs, visit the zeroturnaround site for a free download of the report in its entirety.

RebelLabs: Overturn Your Android Expectations, Puny Humans

| Mobile & IOT| 176 views | 0 Comments
About The Author
- Editor of Voxxed.com, focusing on all things Java, JVM, cloud-y, methodical, future-fantastic, and everything in between. Got a piece of news, article or tutorial you'd like to share with your fellow Voxxians? Drop us a line at info@voxxed.com

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>