Last week I attended AnDevCon in San Francisco (looks like their site already transitioned to the next one in Washington D.C) from Nov. 29th through Dec. 1st. Whenever I attend a conference, the goal is to absorb as much information as I can in order to become a better developer. Between the industry renowned speakers and personal networking sessions AnDevCon presents itself as an opportunity to do just that. The first day of the conference is reserved for full-day or multiple half-day tutorials; this gave the attendees a chance to dive deep into a topic and learn a lot. The next two days were more standard conference fair with 1 hour 15 minute technical sessions, a few keynotes, and various networking opportunities sprinkled in. In this post I wanted to take an opportunity to summarize some of the talks I went to and what I learned.
Embedded Android Workshop with Nougat – Karim Yaghmour
For some background, Karim Yaghmour wrote the book on Embedded Android, literally. This full day class took a deep dive into the Android Open Source Project (AOSP) and how the Android we know and love is built off the Linux kernel. Specifically, the course targeted those who were building Android from source and using it in embedded products. The information presented was still relevant to developers looking to get a better understanding of Android’s internal structure and I was personally interested due to my background in embedded systems.
The class started off with a look at the history of the Android OS, licensing information, and how the AOSP evolved to what it is today. Karim then spoke to the origins of Linux as an embedded OS and how the Linux kernel packaged in Android differs from the standard kernel. From the beginning of the talk there was a lot of emphasis put on the Binder IPC mechanism that Android uses to communicate between services and processes.
The class then focused on peeling away the layers of Android, down to the modified Linux kernel. Once each part had been explored, Karim put it all back together to give a functional view of the Android operating system. As a developer it was interesting to learn exactly how Android handles abstraction, especially from the point-of-view of a user-space application. Learning about the complex internals also gives much more appreciation to the aspects of Android that, as an app developer, are often times taken for granted.
Java 8 for Android – Blake Meike
In this talk, Blake Meike covered important features of the Java 8 API and how they are applicable to Android. The most interesting of the Java 8 features is the incorporation of lambda expressions, a concept that has been around in other languages (such as C#) for some time. He also covered some of the lesser known features, including: type annotations, functional interfaces, method references, default methods for interfaces, and streams.
Interestingly, lambda expressions as we know them in Java are not implemented the same as they are in other languages. With the introduction of functional interfaces, lambdas in Java are simply a syntactic overlay to an anonymous instance of a functional interface that implements the Interface’s single abstract method. Another feature that I found particularly interesting was the introduction of default methods. Previously, when a Java interface was changed it could have an enormous downstream impact on a codebase. This is especially true for libraries, where a developer may not be aware of interface changes until after the library is updated. With default methods, interfaces can declare a default implementation of abstract methods. This helps against code-breaking changes and allows developers to update libraries without worrying about having to track down interface changes.
Finally, it was interesting to learn about how Java 8 is making its way onto Android. The new Jack compiler is constantly being updated and improved, however there are still issues with it, especially when it comes to compiling against libraries. Retrolambda is another option to pull Java 8 features into an Android codebase, and has recently received some great updates. The moral of the presentation was that Java 8 has been available to developers for awhile but is just starting to make a viable appearance on Android.
The slides for this talk are available here.
Google Keynote – Timothy Jordan
The keynote given by Timothy Jordan, leader of Google Platform Developer Relations, was a quick (and I mean quick) overview of Firebase offerings, updates to Android Studio, and Nougat 7.x updates. Timothy made it easy for a developer like myself to get excited about Googles developer support and all of the hard work they put in to make us better at what we do.
Test-Driven Development for Android – Godfrey Nolan
As an Android developer, testing is one of the most difficult processes to properly implement and also to sell to stakeholders. Often times app features are imagined and then developers move straight to slinging code with no though of how that code will be tested later. Test-Driven Development (TDD) is the idea that, for a given feature or part of the code-base, the desired output is known at the time of development. This means a test can be written before the feature is developed. Then the developer can write the minimum amount of code necessary to get the test to pass, refactor, and complete the task. TDD as a development methodology guarantees good code coverage and also enables a developer to assess the progression of a given feature’s development.
TDD can be challenging on Android given the Activity-Fragment-View architecture, but there are tools available to developers to still ensure proper testing is done at each level, especially when it comes to domain specific logic. With the addition of jUnit4 into Android, Google has made it easier than ever to start testing your app from the start. Godfrey ran through examples of how to use jUnit4 in Android, and how Mockito/Robolectric and Espresso can be layered on top for integration and UI testing, respectively. He stressed the goal of unit testing is not to get to a certain percentage of code coverage, that is the wrong mindset. The goal of unit testing (and TDD in general) is to consistently deliver high quality code with the test results to back it up.
The slides for this talk are available here.
MVC, MVP, and MVVM Design Patterns – Godfrey Nolan
In another talk, Godfrey Nolan covered the Model-View-Controller, Model-View-Presenter, and Model-View View-Model design patterns and how they are implemented over the existing Activity-Fragment-View architecture native to Android. This talk was very relevant to his other talk on TDD because properly implementing a design pattern can make testing much easier. The design patterns covered enable (with pros and cons) greater abstraction and more modular design; both of which are ingredients for good testing.
To summarize, MVC is an older pattern that gives better separation between the UI and business logic, but often times the Controller can grow too large. MVP does an even better job of abstracting the UI and domain logic, however there tends to be a lot of boilerplate when implemented correctly and the View and Presenters are tied to the Model’s object type. MVVM gives a much more testable architecture with less code, but it utilizes data binding which is not always appropriate. Finally, at the end of the talk, Godfrey touched on CLEAN architecture. Clean architecture solves most of the problems with basic Android, however the learning curve is steeper than the other architectures.
I highly recommend checking out the slides from this presentation here.
Brillo/Weave Internals – Karim Yaghmour
In this talk, Karim Yaghmour gave an overview of Brillo and Weave from the inside. Brillo and Weave are under active development and those with access to the documentation are forbidden from sharing it publicly. Due to this restriction Karim dug into the project using the open source codebase. In short, Brillo is an embedded Linux platform and Weave is simply a network protocol. Brillo is, almost exactly, the Android OS with the Android part removed.
Brillo could present itself as a powerful embedded Linux distribution that is common across platforms.
Check out the slides for the presentation here.
Escaping Fragments and Making Your Code Modular – Patricia Estridge
Patricia Estridge declared war with Android Fragments and won. In this talk she presents the concept of a native view coordinator/controller on Android as a way to escape having to use fragments. The talk was accompanied by a great code sample that is available on her GitHub. Her solution created modular views, encapsulated activities, smaller activities, concrete UX flows, and added clarity.
I highly recommend taking a look at the slides here.
Android and the Seven Dwarves – Murat Yener
Android is not perfect. While great, the platform itself doesn’t always make development easy. In this talk, Murat Yener presents 7 (kind of) libraries that, when used correctly, fill in the gaps inherent to Android and add powerful functionality.
- Butterknife – Eliminate UI boilerplate via annotations
- Dagger – Powerful, fast dependency injection
- Volley / OkHttp / Retrofit – 3 networking libraries that each serve a different purpose
- GreenBus / Otto – Event bus libraries that allow different parts of your application to communicate asynchronously
- GreenDAO / Schematic – SQL wrappers that take the work out of database management
- Priority JobQueue – Easy async task management
- Timber / Hugo – Logging libraries
It is not usually necessary to use each of these libraries, but they all have project saving qualities. As a final note, Murat also mentioned the Retrolambda library as a solution to introduce the Java 8 functional API to Android.
The slides were fun (but dated). Check them out here.
Obviously I can only cover so much in an already lengthy blog post. There were other talks, keynotes, and networking/social events. I always recommend taking opportunities to attend conferences; they are great opportunities to learn and network with like-minded peers. AnDevCon did not disappoint in this respect, and I am looking forward to attending future AnDevCon events.