{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreiagtjgkuahju7uhcixwfghdsoaow6dn3uqgiwtzo3n25ze5agohxe",
    "uri": "at://did:plc:vyjlfm46mfv6u4vjp6qtrfx2/app.bsky.feed.post/3miyvmcwf2nh2"
  },
  "coverImage": {
    "$type": "blob",
    "ref": {
      "$link": "bafkreidg2k33tiuupnstmiowh7hyyvtsbe3gyhfygiytrzynysnhoctrxi"
    },
    "mimeType": "image/jpeg",
    "size": 81260
  },
  "path": "/articles/two-conversions",
  "publishedAt": "2026-04-08T06:30:00.000Z",
  "site": "https://thedailywtf.com",
  "tags": [
    "CodeSOD",
    "left us",
    "Utilize BuildMaster",
    "Download"
  ],
  "textContent": "The father of the \"billion dollar mistake\" left us last month. His pointer is finally null. Speaking of null handling, **Randy** says he was \"spelunking\" through his codebase and found this pair of functions, which handles null.\n\n\n    public String getDataString() {\n        if (dataString == null) {\n            return Constants.NOT_AVAILABLE;\n        }\n        return asUnicode(dataString);\n    }\n\n\nI assume `Constants.NOT_AVAILABLE` is an empty string, or something similar. It's reasonable to convert a null into something like that. I don't know where this fits in the overall stack; I'm of the mind that you should retain the null until you absolutely can't anymore; like it or not, a `null` means something different than an empty string. Or, if we're going that far, we should be talking about using `Optional` or nullable types.\n\nBut that call to `asUnicode` seems curious. What's happening in there?\n\n\n    private String asUnicode(String rawValue) {\n        if (rawValue != null) {\n            return HtmlUtils.htmlUnescape(rawValue);\n        }\n        else {\n            return rawValue;\n        }\n    }\n\n\nThis function, which is only called from `getDataString`, checks for a null. Which we know it won't get, but it checks anyway. If it isn't null, we unescape it. If it is null, we return that null.\n\nWell, I suppose that fits my rule of \"retaining the null\", but like, in the worst way you could do it. It honestly feels like, if the \"swap the null for an empty string\" happens anywhere, it should happen _here_. If I ask for the unescaped version of a null string, an empty string is a reasonable return. That makes more sense that doing it in a property getter.\n\nThis code isn't a trainwreck, but it makes things confusing. Maybe it's because I've been doing a _lot_ of refactoring lately, but confusing code with unclear boundaries between functions is a raw nerve for me right now, and this particular example is stepping on that nerve.\n\nWhile we're talking about unclear boundaries, I object to the idea that this class is storing `dataString` as an HTML escaped string that we unescape any time we want to look at it. It implies that there's some confusion about which representation is the canonical one: unescaped or escaped. We should store _the canonical_ one, which I think is unescaped. We should only escape it at the point where we're sending it into an HTML document (or similar). Convert _at the module boundary_ , not just any time you want to look at a string.\n\n[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!",
  "title": "CodeSOD: Two Conversions"
}