Empty Reasoning

by in CodeSOD on

Rachel worked on a system which collected data about children, provided by parents and medical professionals. There was one bug that drew a lot of fire: no one could report the age of a child as less than one. That was a problem, as for most of their users, child ages are zero-indexed. One of the devs picked up the bug, made a change, and went on to the next bug.

This was the fix:


Hypersensitive

by in Error'd on

Rational Tim R. observed "When setting up my security camera using the ieGeek app there seem to be two conflicting definitions of sensitivity. I hope the second one is wrong, but if it's right, I really hope the first one is wrong."

1


Zero Competence

by in CodeSOD on

Michael had a co-worker who was new to the team. As such, there was definitely an expected ramp-up time. But this new developer got that ramp up time, and still wasn't performing. Worse, they ended up dragging down the entire team, as they'd go off, write a bunch of code, end up in a situation that they couldn't understand why nothing was working, and then beg for help.

For example, this dev was tasked with adding timestamps to a set of logging messages. The logs had started as simple "print" debugging messages, but had grown in complexity and it was time to treat them like real logging.


The Saddest Words: What If

by in Coded Smorgasbord on

Conditional statements, we would hope, are one of the most basic and well understood constructs in any programming language. Hope, of course, is for fools and suckers, so let's take a look at a few short snippets.

Our first installment comes from Jonas.


One Month

by in CodeSOD on

Joseph sends us a tried and true classic: bad date handling code, in JavaScript. We've all seen so much bad date handling code that it takes something special to make me do the "confused dog" head tilt.

		var months=new Array(13);
		months[1]='January';
		months[2]='February';
		months[3]='March';
		months[4]='April';
		months[5]='May';
		months[6]='June';
		months[7]='July';
		months[8]='August';
		months[9]='September';
		months[10]='October';
		months[11]='November';
		months[12]='December';
		var time=new Date();
		var lmonth=months[time.getMonth() + 1];
		var date=time.getDate();
		var year=time.getFullYear();
		document.write(lmonth + ' ');
		document.write(date + ', ' + year);

A Little Extra Padding

by in CodeSOD on

Today's anonymous submitter supplies us with a classic antipattern: padding via switch:

string TransactionOrder = (string)dr["TransactionOrder"].ToString().Trim();

switch (TransactionOrder.Length)
{
        case 1:
                TransactionOrder = "000" + TransactionOrder;
                break;
        case 2:
                TransactionOrder = "00" + TransactionOrder;
                break;
        case 3:
                TransactionOrder = "0" + TransactionOrder;
                break;
        default:
                TransactionOrder = TransactionOrder;
                break;
}

Infallabella

by in Error'd on

The weather isn't the only thing that's balmy around this parts.

For instance Bruce, who likes it hot. "Westford, MA is usually bracing for winter in December, but this year we got another day of warm temperatures. The feels like temperature was especially nice."


Ready Xor Not

by in CodeSOD on

Phil's company hired a contractor. It was the typical overseas arrangement: bundle up a pile of work, send it off to another timezone, receive back terrible code, push back during code review, then the whole thing blows up when the contracting company pushes back about how while the code review is in the contract if you're going to be such sticklers about it, they'll never deliver, and then management steps in and says, "Just keep the code review to style comments," and then it ends up not mattering anyway because the contractor assigned to the contract leaves for another contracting company, and management opts to use the remaining billable hours for a new feature instead of finishing the inflight work, so you inherit a half-finished pile of trash and somehow have to make it work.

Like I said, pretty standard stuff.


Archives