Thursday, December 5, 2024

CodeSOD: On VVVacation

Programming LanguageCodeSOD: On VVVacation


As often happens, Luka started some work but didn't get it across the finish line before a scheduled vacation. No problem: just hand it off to another experienced developer.

Luka went off for a nice holiday, the other developer hammered away at code, and when Luka came back, there was this lovely method already merged to production, sitting and waiting:

vvv(x, y)
{
	return typeof x[y] !== 'undefined';
}

"What is this?" Luka asked.

"Oh, it's a helper function to check if a property is defined on an object."

Luka could see that much, but that didn't really answer the question.

First, it wasn't the correct way to check if a property existed. Mind you, actually doing those checks in JavaScript is a complicated minefield because of prototype inheritance, but between the in operator, the hasOwn and hasOwnProperty methods, there are simpler and cleaner ways to get there.

But of course, that wasn't what got anyone's attention. What caught Luka up was the name of the function: vvv. And not only was it a terrible name, thanks to the other dev's industriousness, it was now called all over the codebase. Even places where a more "correct" call had been used had been refactored to use this method.

"But it's so brief, and memorable," the developer said.

Luka was vvvery upset by that attitude.

[Advertisement]
Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.

Check out our other content

Check out other tags:

Most Popular Articles