This is what you get when you measure lines of code

Arseni Mourzenko
Founder and lead developer
September 13, 2021
Tags: short 50 quality 36 javascript 3

A few months ago, I wrote an ar­ti­cle about a tech­ni­cal leader who mis­un­der­stood how to mea­sure code qual­i­ty. Try­ing to im­prove things, his only achieve­ment was to make every­thing worse, be­cause of the way bad mea­sur­ing im­pacts a team.

One read­er of this blog con­tact­ed me to share a fun­ny piece of code. He in­her­it­ed it from a team where mea­sure­ments were made, but with ab­solute­ly no thought about the im­pact those mea­sure­ments can have. One fac­tor was the lines of code com­mit­ted per sprint. It wasn't that the pay­check was pro­por­tion­al to the LOCs, but rather that the team was re­ceiv­ing con­grat­u­la­tions or rep­ri­mands based on how many LOCs they pro­duced. The per­son who was writ­ing the least num­ber of lines was re­quest­ed to ex­plain in front of the team why he wasn't per­form­ing as well as his col­leagues.

Here's the re­sult of a one-lin­er (a sim­ple bind­ing of a vis­i­bil­i­ty of a con­trol to a boolean) trans­formed into thir­ty-five lines of text. The guys who wrote it are ab­solute­ly amaz­ing. In par­tic­u­lar, I love the per­fect­ly use­less com­ments which bare­ly re­peat the code, line af­ter line, the if/else split into two sep­a­rate con­di­tions, and, nat­u­ral­ly, the in­ge­nious use of an in­ter­me­di­ary vari­able.

// Initialize the account disabled variable.
let isAccountDisabled;

// Assign user object to a local variable.
const accountInformation = this.user;

// If the disabled attribute from the account information is set to true...
if (accountInformation.disabled) {
    // ... then assign true to the variable.
    isAccountDisabled = true;

// If the account is not disabled...
if (!accountInformation.disabled) {
    // ... then assign false to the variable.
    isAccountDisabled = false;

// Make sure the variable is a boolean.
isAccountDisabled = !!isAccountDisabled;

// If the variable isAccountDisabled is true...
if (isAccountDisabled) {
    // ... then display a message in the console...
    console.log('The account is disabled.');

    // ... and show the popup.
    this.showDisabledAccountPopup = true;

// If the variable isAccountDisabled is false...
if (isAccountDisabled) {
    // ... then hide the popup.
    this.showDisabledAccountPopup = false;