Ryan Harter

Freelance Android Developer

AutoValue Extensions

| Comments

Note This is the third article in a series on AutoValue. The first article introduced AutoValue, the code generating annotation processor for value types. The second took a more in depth look at the code generated by AutoValue, and the benefits of compile time code generation.

In a previous article introducing AutoValue, I briefly mentioned AutoValue Extensions. Now it’s time to go a bit more in depth to look at what extensions are, how they work, and how they can help you get even more out of AutoValue.

An Introduction to AutoValue

| Comments

Value types in Java are hard. Well, not hard, but tedious. Google’s AutoValue library makes them much easier and has just received the long awaited update that adds the flexibility of extensions.

Value Types in Java

Before we can talk about how great AutoValue is, let’s look at the problem it solves: value types.

Dealing With AsyncTask in Unit Tests

| Comments

There may be a shortage of love on the internet for AsyncTasks, but that doesn’t mean they don’t have their uses. I’ve found myself using them a fair bit in the latest project that I’m working on. All in all, they make offloading tasks from the main thread quite simple, but can pose some challenges, particularly in tested environments.

The biggest challenge with using AsyncTask in tested code is that, since the code runs asynchronously, it can be difficult to ensure your tests get the right result for verification. I have seen some solutions for getting around this dilemma, but they involve pretty significant changes to the structure of your app, and exposing some internal members, simply for the sake of the tests.

Should This Be a Library?

| Comments

I come from the consulting world, where it’s common to try to make everything a library. This makes perfect sense, boost profit margins by writing something once and selling it to everyone.

But often times this doesn’t work out as expected for several reasons, the first of which is failing to ask the question “Should this be a library?”

Here are a few tips to help you decide if you should makes something a library or not.