← Previous · All Episodes · Next →
Decoding Developer Disasters: The Mystery of the FFFFFFFF Constant Episode

Decoding Developer Disasters: The Mystery of the FFFFFFFF Constant

· 01:23

|

Hello and welcome to One-Minute Tech WTF. Today we’re looking at “What the FFFFFFFF,” a Resident Line from The Daily WTF by Remy Porter. As Remy puts it, “Computers were a mistake, which is why I’m trying to shoot them into space.” This time the culprit is a Java project full of bitmasks and bitwise operations, built on a network protocol. The developers defined their masks with

private static long FFFFFFFF = Long.parseLong("FFFFFFFF", 16);

That’s right—they parsed an eight-character hex string at runtime instead of using Java’s built-in literal support. You could simply write 0xFFFFFFFF. Worse, the constant isn’t even final, so FFFFFFFF could hold any value at any time. And naming a constant FFFFFFFF hardly makes the “magic number” any clearer. The fix is simple: use a descriptive, final constant and a proper hex literal. That way you avoid parsing overhead, accidental reassignment, and future head scratches. Stay tuned for more quick code cringes next time!
Link to Article


Subscribe

Listen to jawbreaker.io using one of many popular podcasting apps or directories.

Apple Podcasts Spotify Overcast Pocket Casts Amazon Music
← Previous · All Episodes · Next →