Image for post
Image for post

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

Today we’re releasing OkHttp 3.13. With this update we’re bumping the project’s requirements from this:

  • Android 2.3+ / API 9+ (released December 2010)
  • Java 7+ (released July 2011)

to this:

  • Android 5.0+ / API 21+ (released November 2014)
  • Java 8+ (released March 2014)

Cutting off old devices is a serious change and we don’t do it lightly! …

Image for post
Image for post

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

Before we could partition our database we needed to prepare our data model. Here’s how we turned a simple normalized data model into one that could be partitioned for scale.

Normalized Data is Beautiful

The Cash App started as a simple service for sending money. Our MySQL database tracked customers, their linked debit cards, and the payments between them.

Using a normalized persistence model was great! It made it easy for us to iterate on our service. …

Image for post
Image for post

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

At Square, we’re excited about Kotlin. It’s a capable language to build Java libraries and applications with. We love to write code that is both compact and efficient.

We’re also eager to adopt Kotlin’s powerful new features. Kotlin/Native will allow us to share code between iOS and Android. Coroutines make concurrent programs easier to create and maintain.

Today we’re releasing Okio 2.0. In this release we’ve converted the project’s source code from .java to .kt. The conversion lets us use Kotlin in the library and offer APIs that feel right when the calling code is 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

Though it has its wrinkles, I really like JSON. It’s easy to read, pretty fast to parse, and refreshingly simple. Here’s a sample message from GitHub’s exemplar API:

{
"url": "https://api.github.com/repos/square/okio/issues/156",
"id": 91393390,
"number": 156,
"title": "ByteString CharSequence idea",
"state": "open",
"created_at": "2015-06-27T00:49:40.000Z",
"body": "Let's make CharSequence that's backed by bytes.\n"
}

Kotlin’s concise immutable data classes make it easy to build a basic model for this JSON.

data class Issue(
val url: String,
val id: Long,
val number: Long,
val title: String,
val state: String,
val created_at: String,
val body…

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

Yesterday I wrote about how we’re rolling out @Nullable throughout Square’s open source Java libraries. It helps our tools to alert us of possible NullPointerExceptions.

Image for post
Image for post
IntelliJ warns about potential NullPointerExceptions

The @Nullable imposes an obligation on the consumers of the value: they must prepare for it to be null. But what happens when I’m the one producing the value? Suppose that I’m calling the method above.

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

Lots of us have strong opinions on null. I don’t think it’s evil, or that using null is sloppy. I just want to be deliberate: wherever a parameter or return value can be null, the interpretation of that should be explicit.

/** 
* Consumes the next line of text and returns it.
* Returns null if there are no more lines.
*/
String readUtf8Line() throws IOException;

Kotlin’s great because it requires us to be explicit when we use null. Declaring the same method in Kotlin puts null into the type system. …

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

It’s rare for a programmer to get to work on the same problem twice. Either the first is good enough and you’re done, or it wasn’t and you’re foolish to try again. Circumstance and hubris have given me two opportunities to make another attempt.

Guice, a Dependency Injector

When I started at Square in 2012, the Android team was using Google Guice for dependency injection. I’d contributed to Guice and so it was nice to use familiar code at my new job. But there was a problem: Guice was too slow for mobile. …

About

Jesse Wilson

Android and jokes.

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