SQL Multiple-Column IN Clause

The IN clause is handy. I use it all of the time. SELECT * FROM cars WHERE make IN ('Ford', 'Subaru') AND price < 5000; +--------+---------+------+--------+-------+ | make | model | year | color | price | +--------+---------+------+--------+-------+ | Ford | Focus | 2007 | Black | 1100 | | Ford | Mustang | 2005 | Yellow | 4000 | | Ford…

Developer Identity & Multiplatform

We don’t self-identify as software developers but as web developers, backend developers, Android developers, or iOS developers. Many factors reinforce this specialization. I’m a Droid Building systems builds experience. Android developers learn technologies that have no analog on other platforms: activities, intents, and XML layouts. Once we’ve…

URL Encoding Is Material

Lots of OkHttp and Retrofit users have reported bugs complaining that URL special characters (like + ; | = * ; ; | or *) weren’t encoded as they expected. Why can’t HttpUrl just encode ; as %3B? Extra escaping is safe in most programming languages and document formats. For example, in HTML there’s no behavior consequence…

A Clever, Flawed OkHttp Interceptor Hack

All of OkHttp’s configuration is on the OkHttpClient instance: OkHttpClient client = new OkHttpClient.Builder() .readTimeout(2_000, TimeUnit.MILLISECONDS) .writeTimeout(2_000, TimeUnit.MILLISECONDS) .cache(new Cache(cacheDirectory, cacheSize)) .build(); This design is minimal and simple. There aren’t any precedence rules or hidden settings to be surprised by.…

Canonical URLs for Javadocs

We publish separate Javadocs for each major release of OkHttp: 1.x, 2.x, 3.x. This is intended to help you out when you’re using an old version. But it’s had an adverse side-effect: Googling for “responsebody okhttp” only returns results for old versions. You see the…

Story Code

Designing APIs is hard. One technique that helps me is to tell a story with the code: I’ll make a sequence of calls to show how things fit together. I find this helps me to discover what methods I need and what I can leave out. Using features together…

Name Your Threads

I work on a big Java service that does lots of things. When I snapshot the application’s threads I can see it’s got lots going on: Talking RPC and HTTP Running cron jobs and job queue jobs Persisting to MySQL Coordinating with ZooKeeper Collecting garbage At a glance…

Seductive Code

It’s careful work balancing tradeoffs when writing code and designing APIs. Here’s some everyday Java code: for (Protocol protocol : protocols) { if (protocol != Protocol.HTTP_1_0) { result.writeByte(protocol.toString().length()); result.writeUtf8(protocol.toString()); } } On Android—where garbage collector costs aren’t necessarily negligible—I make my…