prashant joshi

Case study · 2021 · Java

Designing a library by building its first user

The itch

By mid-2021 I had written the same networking code three times: chitChat on desktop (Feb), chitChat on web and Android (May), and small multiplayer games in codeholic. Each project had its own accept loop, its own message format and its own “tell the UI something happened” glue.

The bet

Pull the plumbing out once, as a library, JavaServerClientAPI (JSC). Then prove it by building something real on top of it within days, not months. Gameholic was started five days after JSC’s first commit.

What I built

Decisions and trade-offs

Decision Why then What it cost What I’d do now
Thread per connection The simplest correct model for tens of players Doesn’t scale to thousands of connections NIO/Netty or Java 21 virtual threads
Human-readable delimiter protocol Debuggable with telnet Delimiters aren’t escaped, so field decoding can break Length-prefixed JSON or binary with a version field
A relay that doesn’t understand games No server change per game The server can’t validate moves; clients are trusted Optional per-game validators on the server
In-memory sessions No infrastructure needed for a student project Not thread-safe, lost on restart, predictable IDs ConcurrentHashMap with TTL, or Redis; random IDs

Revisiting it in 2026

I came back to both repos with fresh eyes and tests:

What it taught me

JavaServerClientAPI · JavaDocs · Gameholic · Gameholic docs