Get ready for another RebelLabs report — coming at you like a shot of caffeine, straight into the brain! More entertaining than Jar Jar Binks’ scriptwriter (OK, a lot more entertaining than that!), yet still as informative as an informant with extremely informative information.
This time around, we focus on Android, a market which many people have identified as the reason for Java’s ongoing popularity.
Android, what is it?
Well, since you ask, it’s a robot or synthetic organism designed to look like a humanoid and — oh no, damn wikipedia disambiguations! Android is a Linux-like operating system, designed for touchscreen devices like smartphones or tablets. Java is the official programming language for Android applications, although you can also write code in Kotlin, GO, C++ and many other languages.
You have most likely picked up this report because you have a Java background, so you are familiar with some of the great Java content available via RebelLabs. There will also be a number of readers who do not have a solid background in Java, but have been learning it to write an Android application themselves.
There are a number of lessons that need to be learnt in both camps. Those who already have Java experience, know about the Java ecosystem and need to focus more on the intricacies of the Android platform.
It is equally important to let go of several premises that are more suited to backend development — and have less relevance with Android. Those who come from the Android route (Welcome to all of you!) need to be made aware of some exceptional tools, libraries and patterns that Java developers have taken for granted over the last couple of decades. It is important that these skills and trusted practices are ported, so that we are not trying to find solutions for problems we have already fixed. Whichever route you came down, we hope this report helps you along on your path to droid-greatness!
What is in this report
This report takes a broad range of topics that are relevant for either existing Java developers, moving across to Android, or existing Android developers who are newcomers to Java. We start with one of the biggest differences between Android development and Java development — the devices. The runtime environment is not an issue with core Java development. With Android however, this environment is much more important. This is due to the fact that the eventual user interface of your application is key to its success — or demise.
We continue with a look at a number of core topics: including performance, how to use proper code patterns, and the parallelization model. We also look at how Android differs from our current understanding of a more traditional Java server-side application. Testing is next — an extremely important aspect of software engineering. Unfortunately, testing still gets forgotten or left behind in the wake of developers frantically shoehorning functionality into the next release.
The final section of the report looks at the available tooling, making your life as a developer even easier. You can also work faster with some productivity enhancers that easily integrate into your environment. We look at static code analysis tools that will be familiar to an experienced Java developer. These can improve your codebase and find issues earlier in the development cycle. But first, let’s bust that jargon!
Talk like a droid
It is important to brush up our lingo so that we will not have translation issues throughout the report. First of all, keep the following laws in mind:
- A robot may not injure a human being or, through inaction, allow a human being to come to harm.
- A robot must obey the orders given it by human beings except where such orders would conflict with the First Law.
- A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws.
Android SDK/APIs: The Software Development Kit for Android provides a bunch of sample projects with source code, an emulator, and all the Android libraries and APIs that allow you to build your own Android application.
View is an Android class (
android.view.View) that is used to construct the user interface of an Android application. Prebuilt views are provided by the Android SDK, including buttons, check boxes, progress bars and more. These are often referred to as widgets. Views can be comprised of other views, which are in turn called composite views.
Activities: An activity is a single task that
a user can do, often interactive. The
Activity class (
android.app.Activity) creates a window. You can then add a view to this
activity programmatically. An application can have many activities and it can switch between these activities.
Fragments: A fragment is a sub-activity, for the lack of a better word. The
Fragment class (
android.app.Fragment) enables you to design your code in a more modular way. You can add and remove fragments to and from an activity even while it is running. Like activities, fragments have a lifecycle, so you can easily keep the history and state information.
Dalvik: This is a Android Virtual Machine, the runtime that hosts your applications. It sits on the Android OS. It uses a Just-In-Time (JIT) compiler to interpret bytecode into machine instructions. As of Android 4.4, a newer virtual machine, ART, has been introduced. Dalvik has since been discontinued, but it is important to be aware of the role it has played.
ART: This is the new and improved Dalvik replacement. ART introduces Ahead-Of-Time (AOT) bytecode compilation, generating machine instructions at installation and startup time, as opposed to the JIT runtime model. This makes applications slower to install, adds a bigger footprint, but is significantly faster
Now that we are clearer with our vocabulary, we can start the report!