Years ago, Stefan's company was short handed, especially on the developer team. But they had a large hell-desk support team. And at some point, someone had the genius idea: "PHP is easy for anyone to learn, and so our helpdesk folks should have no problem. Let's hand them development tasks." Which meant Stefan inherited lots of lines which look like this: $bgc = $tno ? '#FFFFFF' : '#FFFFFF'; Unlike many examples of this pattern, this is not the result of a pre-processing or templating step generating a conditional where both branches are the same value. Someone actually typed this. Also,…
Alastair found this comment in his codebase, and wondered, "who wrote this comment?" A quick blame answered the question: he did. He did not, however, write the code. public function getAllMailers() { // This function neither returns Mailers, nor all of them. ... } I suppose the comment was easier to add that doing a global find/replace to update the function name everywhere. But I do wonder, what does this function return? In any case, sing along: "I wrote the comment, but I did not pick this function name". [Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with…
We all love format strings for generating human readable text. Certainly, they're a better choice than string concatenation. Even if I have a blind spot that keeps me from remembering the printf format tokens, I still prefer to use format strings. Jasmine has a co-worker that does use format strings, but they also miss using string concatenation. So they've found a way to combine them, and avoid the perils of making readable code that describes the format of their text. myField.DataFormatString = "{0:#,##0." + new string('0', 2) + ";(#,##0." + new string('0', 2) + ")}"; Now, in their defense,…
Mandy's co-worker recently learned about virtual inheritance in C++. It's become their new favorite button to push, and they only use virtual inheritance. Virtual inheritance is one workaround for the "diamond problem", where you have an inheritance tree that "recombines" via multiple inheritance: when a child class has a Hapsburg-esque parentage, it's hard to decide which inherited methods are being invoked or overridden. In C++, imagine you have class A, which gets derived into classes B and C. Class D then uses multiple inheritance to inherit from B and C. In practice, this means that D…
Nikolai M's team had a flaky CI/CD build. About 0.5% of the time, one of their tests would fail: frequent enough to be annoying, but not so frequent that it motivated management to assign anybody to investigate. Nikolai eventually dug in, taking the initiative. Microsoft's implementation of UUIDs calls them GUIDs. The GUID is, per the docs, really just a wrapper around UUID algorithms, and supports a variety of different UUID variants. I'm sure at some historical point, this wasnt't true, and Microsoft had some weird internal algorithm. That's not really here nor there, but the test that was…
Today's representative comment ran out of room. int maxLen = getColumnSize(session, "audit", "text_value1") - 16; // Leave some room for No, it isn't continued on the next line and just got trimmed out, except perhaps by a careless merge. This is the entire comment. Clearly, written by David Chase, the creator of "The Sopranos". There are so many things we might be leaving room for. We could leave some room for dessert. Leave some room for activities. Leave some room for the holy spirit. Leave some room for improvisation. [Advertisement] ProGet’s got you covered with security and access…
There are many cases where some sort of debugging block sneaks by, especially cases where we see preprocessors or templates working, which leave us with nonsense like if (true == false) running in production. But Codemonkey found a new twist on that sort of thing, in a SQL query being run in production. WHERE (some conditions) AND (1 = 0 OR (1 = 1 AND (other conditions))) The OR means that by twiddling the first equality check, we can toggle "always return rows" with "return based on condition". Toggling the second we can make it "never return rows", which I'm not certain is actually useful.…
Today's maybe more of a "representative data sheet entry" than anything else. Every developer has the experience of reading the documentation. If you've been at this for some time, you've probably read bad documentation. Documentation that is incomplete, inaccurate, or otherwise flawed. Or, my personal favorite, the brief time where Oracle tried to put all of its documentation into an Adobe Flex site (aka, a Flash application, not a real web app). That one had fun bonus features, like "breaking copy and paste" and "preventing you from deep linking to a piece of the documentation". But…
Optional Google Analytics helps us understand visits. Microsoft Clarity records masked interactions to improve the site. Optional tools stay off unless you choose them. Privacy details.