Good method names are one of the primary ways to write self-documenting code. The challenge there, is that documentation often becomes out of date.

Take this delectable PHP nugget, from Nathaniel P, who has previously been tortured by bad date handling.

function deleteTenDays()
{
        
        $thedel = $this->db->query('Delete FROM ClientReportsRelationship where DateEntered <= (CURRENT_DATE - Interval 31 DAY) ');
        
}

The function is called deleteTenDays. The comment tells us that it “delects everything” from the table “minus 3 days”. The actual delete query deletes everything older than a month. For bonus points, there’s a commented out query which just deletes everything from a single customer.

Honestly, this function needs to be delected.

[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.

Remy Porter

Source link

You May Also Like

Small Child who can’t swear at home or school, swearing at his grandparents

Four-year-old Joshua Atkinson from Mithering on the Trent has been told off…

Terning Nulls into Values

A former co-worker of David S wanted to check for nulls, and…

Behold My Holiday Illusion

“Photo of my two brothers, my sister-in-law and myself (the head apparently…

Ripping the Headlines Today – Paul Lander, Humor Times

Making fun of the headlines today, so you don’t have to The…