Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
such a nice boy
Mar 22, 2002

return0 posted:

While I've got nothing as bad as that which has been posted, a colleague of mine was looking through some of my code and found something equivalent to this gem:

code:
private void SomeFunc(double _a, double _b)
{
    if(_a / _b > 1)
    {
        //...do stuff...
    }
    else
    {
        //...do other stuff
    }
}

What's wrong with that code? Is it just that
code:
if (_a > _b)
would have been better?

Adbot
ADBOT LOVES YOU

such a nice boy
Mar 22, 2002

At my last job, we hired a guy who was supposed to be pretty good at...well...some technology. I won't say which, because you'd be able to figure out who it is. In fact, he was one of the coauthors of the O'Reilly book on it, so we assumed he really knew his stuff.

Our product was written in Java, and he was supposed to write the section dealing with this technology. 2 days before we were supposed to code freeze, he's freaking out, saying that nothing works and he can't figure out why. I look at his code.

First clue something was wrong: he's storing EVERYTHING as strings. Integer return codes? Strings! Boolean values? "True" and "False". Casting them to ints or bools every time he needs to use them, which is pretty often.

Sometimes the casting was insane. I would see things like this:

code:
String numPorts;

try {
   doSomething(Integer.toInt(Integer.toString(getIntValue(numPorts))));
} catch (Exception e) {
} 
all over the drat code. What's worse is that he would try to get return values in strings that were passed as parameters. So the above code would really look like this:


code:
String numPorts;

String result = null;
try {
   doSomething(Integer.toInt(Integer.toString(getIntValue(numPorts))), result);
} catch (Exception e) {
}

if (result != "worked") {
   ...error handling code...
}
I walked over to my manager's office and showed him the code. His jaw almost hit the ground.

I spent the next 2 days and nights trying to figure out what the guy's code was really supposed to do, finding all the copy-pasted code, refactoring, and getting rid of the numerous unnecessary "factory" classes and abstract classes that he tried using in his failed attempts to get his code to work.

such a nice boy
Mar 22, 2002


What's wrong with it? There's no way I'm going to make the mental effort to try to parse out what that regex does.

such a nice boy
Mar 22, 2002

nebby posted:



Is that a lesbian porn button under the YouTube button? And why is there a Shakespeare button? Is that to solve the "million monkeys at a million typewriters" problem?

such a nice boy
Mar 22, 2002

That Turkey Story posted:

Holy moly fucckkkk!!!!!!!!!! Uggg I just want to kill myself! Yuck! Two loving spaces? God dammit!

poo poo...

Dude, whitespace changes can be incredibly annoying, and sometimes autocorrect functions don't work well.

such a nice boy
Mar 22, 2002

CT2049 posted:

I understand what you mean, but that's not what's happening here. I'd get questioned for writing
code:
if( foo.equals(foo2) )
but when I started writing like this:
code:
if( foo.equals(foo2) == true)
they'd all understand it. I have no idea, and I cringe everytime I do it, but it makes reviews of my code go faster.

The only thing I can think is that then you can glance and easly see if your checking for the true case or the false case, but even that is so simple the == shouldn't be necessary.

That's ridiculous. The first one reads like an english sentence; who could possible have a hard time reading it? It's like the difference between saying "my name is Bob" and "my name is Bob is a true statement".

such a nice boy
Mar 22, 2002

I'm fixing an application right now for a children's foster home. Previously, they went with the lowest bidder they could find ($20/hr, I think). That guy apparently subcontracted it out to someone who charged even less. None of them understood databases or DRY or much of anything. Here's some of their work:

code:
	if($behavior["BehaviorGroupID"]==70)
	{
		if($behavior["BehaviorID"]==148)
			$this->childimmediaterecall="intact";
		else if($behavior["BehaviorID"]==149)
			$this->childimmediaterecall="mild loss";
		else if($behavior["BehaviorID"]==150)
			$this->childimmediaterecall="moderate loss";
		else if($behavior["BehaviorID"]==151)
			$this->childimmediaterecall="severe loss";
		else 
			$this->childimmediaterecall="";
	}
Hey, some of these text fields might have more than one line of information. How could we put that into a PDF?
code:
$this->childeducational= $clientIntake[0]["EducationAssessmt"];

$this->childeducational1=substr($this->childeducational,0,100);
$this->childeducational2=substr($this->childeducational,100,100);
$this->childeducational3=substr($this->childeducational,200,100);
$this->childeducational4=substr($this->childeducational,300,100);
$this->childeducational5=substr($this->childeducational,400,100);
$this->childeducational6=substr($this->childeducational,500,100);

...

$this->Text(20,65,$this->childeducational1);
$this->Text(20,70,$this->childeducational2);
$this->Text(20,75,$this->childeducational3);
$this->Text(20,80,$this->childeducational4);
$this->Text(20,85,$this->childeducational5);
Note the misspellings. They're all over the place. I think I've seen "client" spelled 3 different ways.

The PDF rendering code is broken up logically into "RenderPage1", "RenderPage2", and so on. So if I want to delete a section, everything has to be moved "up a function" to get the pagination right.

I hate this codebase so much. The guys who wrote it have been working on it since last November.

Adbot
ADBOT LOVES YOU

such a nice boy
Mar 22, 2002

qntm posted:

This isn't really a coding horror, it's more of an absence-of-coding horror. What is the thought process that leads to an omission like that? I have severe problems attributing this to malice or incompetence, it has to be literally "I'm writing a program which lets people retrieve files and directories from remote locations. Oh, but not directories. I think I'll leave that bit out."

I could see good arguments for making this a client responsibility. You keep the FTP protocol simple: only allow listing files and downloading one file at a time. Given those tools, the client can implement recursively downloading directories.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply