Code More Efficiently

Anyone who has developed an application from an early stage will agree that the development process contains a ridiculous amount of boilerplate. If you’re unfamiliar with the term boilerplate, this Wikipedia article could help you get started. Boilerplate is “is the sections of code that have to be included in many places with little or no alteration”.  The problem isn’t that boilerplate is unnecessary, on the contrary, boilerplate code is actually quite necessary (If you’re planning on arguing against this, try writing a program without using methods). The main issue is that the time you spend on the boilerplate code would be so much better spent on the actual functionality of your app.

It’s a dirty job, but someone has to do it

Dirty Toilets in Antigua, Guatemala by Sjoerd van Oosten
Wouldn’t it be nice if someone wrote it all your boilerplate for you so that you could get to what’s important? Well, I’m here to tell you that many already have and no, smart ass, I’m not talking about the SDK that you’re using to develop your app. I am talking about the numerous open source libraries out there that you can use. No matter how new and unique your app is, you’re going to run into the same problems as many before you have and some of those nice and friendly developers have shared their work, free of charge, on beautiful places on the internet like Stackoverflow, Github, Bitbucket, and more. All you have to do is reach out and get it. Make sure the licensing terms work for you (Most are licensed under the Apache v2 Open Source License). Don’t re-invent the wheel.

Sharing the wealth

Over the next while, I’ll be writing about the libraries that my colleagues and I used while developing Hookt for Android. As I publish the articles, I’ll update the entries below to contain a link. Bookmark this page and you have bookmarked them all. The libraries mentioned below are mostly meant for Android/Java, but the overall message is platform agnostic: The less time you spend writing boilerplate, the more time you have to develop what’s yours.


Lombok is a lightweight Java library that promises to “spice up your java”, but what it really does is generate your boilerplate code for you through annotations. Until I publish my Lombok post, you can read about it at or watch this video.


Butterknife is a view “injection” library for Android. If you don’t know what that means, here’s a hint: You have no idea how sick and tired of typing findViewById you are until you don’t have to type it anymore. While I get my stuff together and write something about Butterknife, you can get to know it here.


Picasso is a powerful image downloading and caching library for Android. Picasso can load, download, cache, resize, and transform your images. It handles placeholders, error images, and even custom transformations (e.g. blurring, colour filters, etc). While I work on finishing my Picasso post, you can learn all about Picasso on Square’s Github portal.

Google GSON

Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of. Don’t take my word for it, though, read about it here.  That’s where I ripped the above text from.


Retrofit is a “A type-safe REST client for Android and Java”. That may not sound a like a lot, but if you’ve written a REST API client, you’re gonna love it: Retrofit lets you write your REST API methods as a Java interface. It takes that interface and generates code that actually interacts with your REST API server. It works very nicely with GSON. You wanna read more about it? Jake Wharton (the author of Retrofit) had a presentation about it  at the Netflix Open Source Meetup in July 2014.