Wednesday, June 12, 2024

The Download: Apple’s AI plans, and a carbon storage boom

At its Worldwide Developer Conference...

The Unrealized Potential Of Olfactory Design — Smashing Magazine

Kristian Mikhel covers various practical applications...

A Poorly Pruned Branch – The Daily WTF

Programming LanguageA Poorly Pruned Branch - The Daily WTF

Juliano had this very non-WTF bit of PHP code:

if (!$path) {
} else {

After another team member made a commit, however, the code turned into this:

if (1 == 2) {
} else {

Now, generally, when I see 1 == 2 type expressions, I just assume that this is a templated, generated bit of code. I usually (but not always) avoid using those as WTFs. But here, we have an actual case where the developer manually changed the code because they wanted to disable a branch. There is no comment, the commit message isn’t helpful for understanding the change. You just have this awkwardly mysterious bit that now lives in the code, with no clear history and no clear purpose.

In an ideal world, you’d just delete the dead code and let version control history worry about previous versions. In a less than ideal world, you’d comment why you disabled the branch, in-line in the code (and also in the commit, and arguably a few other places). Instead of putting in a nonsense condition, perhaps you do a if (!path && false) { //disabling this branch because X instead.

But no, we did none of that. Now we just have a mystery, lingering in the code, waiting for future developers to stumble across it and ask, “WTF?”

Otter – Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!

Check out our other content

Check out other tags:

Most Popular Articles