Factory Factory

I use lots of factory classes in my code. But not everywhere. I don’t like the ceremony they require to create and use: why not a constructor? Factories don’t solve a business problem directly; they solve an architecture problem. They feel enterprisey and architecture astronauty. /** * For example, a…

Code Changes Should Be Small or Mechanical

Easy code changes are additive: introduce a new database table, network call, or screen. Difficult changes are transformative: split a database table, combine a few network calls, or change a component that’s used on many screens. These changes tend to motivate refactoring: Introduce feature flagsExtract interfacesMove code between modulesAdd…

Optimization is Specialization

One aspect of programming that’s more art-than-science is making things efficient. I love finding shortcuts that make a system work better! It’s particularly satisfying to gather insights that we can exploit! I’ll illustrate with an example. Optimal for TodayHttpUrl is a class I wrote that implements URL…

Induced Demand & Code

This post expands on a section in my Writing Code That Lasts Forever talk. Here's what it takes to release a new version of OkHttp: Confirm the code is in a releasable state!Name the version (5.0.0-alpha.10 ?, ick)Summarize what’s new in the changelogTag the release…

Selection Bias in Hiring & Promotions

Let’s make a fictional company that employs workers in two levels: Senior worker: does important work; gets paid $50/hour.Principal worker: trusted with the most important work; gets paid $100/hour.Unfortunately, it’s difficult to differentiate the two levels! If a project completes early it might because…

Jesse’s Slide Decks

I presented Nerding Out on Okio at Android Worldwide last month. After sharing the video link and slide deck, Andrew Kelly tweeted asking if I’d share my process. I’m flattered by the question! So here I’ll indulge and share what works for me. The gist of my…

EventListener is Like Logging, But Good

In 2013 I opened OkHttp Issue #270, ‘Analytics API’. The request was to just add some debug logging: We should add verbose logging for the response cache. Folks occasionally are puzzled when the cache doesn't work. Let's make it easy for them to figure out why.We didn’t add…

Uncertainty in Tests

I’ve been working on OkHttp’s Happy Eyeballs and exploring testing strategies along the way. Happy Eyeballs is the fun name of RFC 6555, which is a clever hack to deploy IPv6 even if some client’s IPv6 connectivity is unstable. Here’s how it works: A client has…