サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
画力アップ
publicobject.com
Certain TLS features like Server Name Indication (SNI) and Application-Layer Protocol Negotiation (ALPN) existed in Android before they had public APIs. The code was there; there just wasn’t a good way to use it. OkHttp hacks around such limitations with reflection. Our internal platform package integrates both Android and JVM-specific features to get the best behavior even when public APIs don’t
Lots of object models primarily track application state. For example, OkHttp’s Http2Connection.kt has state for whether a ping’s reply is outstanding: private var awaitingPong = false This is set to true each time a ping is sent and then false again when its reply is received. I’ve recently started to prefer models that primarily track facts instead. For example: private var pingsSent = 0L private
LinkedHashMap is always better than HashMap Published on 2016-02-08 Deterministic code is much easier to debug & understand than non-determinstic code. Got a test that’s failing? Launch the debugger, step through the code, and find the exact statement where an assumption is violated. For me this often looks like a binary search. I add breakpoints and make assertions like “everything is fine before
We’re in a golden age of reusable open source code. With GitHub and Maven Central it’s never been easier to create and share code. This is excellent! Android developers have access to a steady stream of new projects. I keep up by following some Android developers on Twitter and by subscribing to Android Weekly and #AndroidDev Digest. Releasing a new open source project is fun. Take your most reusa
An awkward API OkHttp 1.0 started out as an optimized implementation of HttpURLConnection. This old API is awkward to implement because there is an implicit state machine that corresponds to the underlying network I/O. GET / HTTP/1.1 Host: publicobject.com Accept: text/html HTTP/1.1 200 OK Content-Length: 300 <html> <head><title>Public Object</title></head> ... For example, calling getResponseCode
In announcing OkHttp's new URL class, I wrote about how parsing returns null instead of throwing exceptions: Instead, parse() just returns null when it doesn’t understand what you passed it. Several developers thought this was a lousy API. Derek Morr tweeted: "parse() just returns null" so, not sane. And Alex Hvostov redditted: Are you fucking kidding me? What is this, PHP? Well, the method return
Lately I've been building HTTP APIs for Square Cash, to be used by our website and partners like Snapcash. It turns out this is a particularly difficult task because I need to balance two competing concerns: Keep separate things separate. If the app wants to look up payments 123, 246 and 369, it should make three requests for /payments/123, /payments/246, and /payments/369. This is simple and mana
Robert Konigsberg, Jerome Mourits and myself have written several snippets that highlight the carefully designed Google Collections Library: PreconditionsPreconditions.checkNotNull(order.getAddress(), "order address"); Iterables.getOnlyElementassertEquals(jesse, Iterables.getOnlyElement(usersOnDuty)); Comparators.maxreturn Comparators.max(perKm, minimumDeliveryCharge); Objects.equal and hashCodere
このページを最初にブックマークしてみませんか?
『Public Object』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く