Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Programming frequently deals in visible changes: the logic in your code, the dependencies you declare, the API you expose. There is, however, quite a bit of associated hidden change: transitive dependencies, generated code, and manifest files.

In code review we focus on the visible because that is what is presented to us in the diff.

A visible logic change in a pull request.

It’s equally as important to pay attention to the hidden changes during code review. Transitive dependency changes or generated…


Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Java code generation has become a popular solution to simplifying library code. Dagger generates interface implementations, Butter Knife generates Android UI boilerplate, and Wire generates implementations of value classes for binary encoding of data.

Despite Kotlin’s strong interop with Java, the generated Java code for these libraries can feel foreign and convention-violating as they’re targeted at Java consumers and lack Kotlin features.

Today we’re happy to announce KotlinPoet, a library for generating Kotlin code!


Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

With nullability being a first-class citizen in Kotlin’s type system, the need for an Optional type seems all but diminished. Just because you can explicitly express nullability, however, does not mean that null is always allowed.

For example, Retrofit provides adapters for RxJava 1.x and 2.x which allow modeling your requests as a single-element stream.

interface MyApiService {
@GET("/api/user/settings")
fun userSettings(): Observable<Settings>
}

RxJava 2 differs from RxJava 1 in that it does not…


Improving the developer experience of Square’s libraries in Kotlin.

Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Consumers of Square’s open source libraries may remember our “Seven Days of Open Source” prior to Google I/O 2013. We released major versions of some of our projects in the days leading up to the event. This culminated in us also having a booth inside the developer space at I/O and getting to meet and chat with you all about those projects and others.

While we don’t have seven projects to release this year…


Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Unlike the traditional request/response model of HTTP, web sockets provide fully bi-directional streaming of messages. This means that both the client and the server can send any number of messages to the other peer at any time. With today’s version 3.5 release, OkHttp now offers native support for web sockets!

Connect a web socket by passing a request to the newWebSocket() method along with a listener for server-sent messages.

OkHttpClient client = new OkHttpClient();


Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Recently, Ron Shapiro and David P. Baker from Google joined me to present a pair of tech talks in Square’s New York City office. (Thanks to everyone who attended!) These talks were recorded and are now available on our Square Engineering YouTube channel. Enjoy!

10 Kotlin Tricks in 10(ish) Minutes by Jake Wharton
Understanding Dagger 2’s Generated Code by Ron Shapiro and David P. Baker

Don’t forget to subscribe to the YouTube channel for more great content in the future!

Jake Wharton

Stop stopping.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store