"I've been trying to fix up the last project a colleague completed before heading for greener pastures," wrote Philip Tyre. "After finding this comment, I'm beginning to have bad thoughts about what I may find lurking around..."

//  Apparently, in at least on situation, a Statically declared public
//  variable will hold its value across different browser instances making calls to the
//  same web page.
//  For now, reset these variables on Page_PreInit.

 

"In Java, all classes extend the Object superclass by default and by design," Steve writes, "but just in case someone finds a way around that, we've got this unit test to make sure this magic code doesn't slip through the cracks."

/**
 * Tests if {@link XXXX} class extends {@link Object} class.
 */
@Test
public void testInheritance() {
    Assert.assertTrue("Class does not extends Object class.",
        instance instanceof Object);
}

 

"There are many ways to convert a number to a negative," writes Rafael L, "this, I suppose, is one of them."

// Convert to negative number
varInt := StrToInt('-' + IntToStr(varInt));

 

"We have some notoriously bad code in our project," wrote Robby Lann, " so much so that the Compiler throws a 'SHEEIT' Exception and advises us to start over."

Error  7     A problem occurred while trying to set the "Resources" parameter 
             for the IDE's in-process compiler. External component has thrown 
	     an exception.
Error  8     The "Vbc" task failed unexpectedly.
             System.Runtime.InteropServices.SHEEITException:
	       External component has thrown an exception.
	       at Microsoft.Build.Tasks.Hosting.IVbcHostObject.EndInitialization()
	       at Microsoft.Build.Tasks.Vbc.InitializeHostCompiler(IVbcHostObject vbcHostObject)
	       at Microsoft.Build.Tasks.Vbc.InitializeHostObject()
	       at Microsoft.Build.Utilities.ToolTask.Execute()
	       at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy 
	         engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, 
		 ITask task, Boolean& taskResult)
Error  9     Visual Basic compiler is unable to recover from the following error: System Error 
             &Hc0000005& (Visual Basic internal compiler error)
             Save your work and restart Visual Studio.
Error  11    A problem occurred while trying to set the "Resources" parameter for the IDE's 
             in-process compiler. External component has thrown an exception.  
Error  12    The "Vbc" task failed unexpectedly.
             System.Runtime.InteropServices.SEHException: External component has thrown an exception.
               at Microsoft.Build.Tasks.Hosting.IVbcHostObject.EndInitialization()
               at Microsoft.Build.Tasks.Vbc.InitializeHostCompiler(IVbcHostObject vbcHostObject)
               at Microsoft.Build.Tasks.Vbc.InitializeHostObject()
               at Microsoft.Build.Utilities.ToolTask.Execute()
               at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, 
	         ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)      
Error  13    A problem occurred while trying to set the "Resources" parameter for the IDE's 
             in-process compiler. External component has thrown an exception.
Error  14    The "Vbc" task failed unexpectedly.
             System.Runtime.InteropServices.SEHException: External component has thrown an exception.
               at Microsoft.Build.Tasks.Hosting.IVbcHostObject.EndInitialization()
               at Microsoft.Build.Tasks.Vbc.InitializeHostCompiler(IVbcHostObject vbcHostObject)
               at Microsoft.Build.Tasks.Vbc.InitializeHostObject()
               at Microsoft.Build.Utilities.ToolTask.Execute()
               at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, 
	         ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)      
		 SiteConvert

 

"I found this piece of code in the SDK from leading microchip vendor," Jérôme wrote, "this array is used for parsing commands arguments from their embedded command line."

static struct boolean_s boolean_table[] = {
    {"Yes", TRUE},          {"OKay", TRUE},
    {"YOUBET", TRUE},       {"True", TRUE},
    {"1", TRUE},            {"0", FALSE},
    {"ON", TRUE},           {"OFF", FALSE},
    {"No", FALSE},          {"NOWay",FALSE},
    {"False", FALSE},       {"YEAH", TRUE},
    {"YEP", TRUE},          {"NOPE", FALSE},
    {"NOT", FALSE},         {"Maybe",__TIME__[7]&1},
};

 

"I found this while diving into the config of a service that cleans up a production area on a SAN," Owe Jørgensen wrote via the Submit to The Daily WTF Visual Studio Extension, "I have never felt a more compelling urge to uncomment that line and push it into production just to see what happens."

<appSettings>
  <!-- 
  <add key="SleepOnWake" 
       value="Dont uncomment this. Just dont. It will unleash a horde 
              of unpleasant rabid dogs upon you, and make sure your life 
	      is miserable until you comment it back again. 
	      Rabid dogs are quite unpleasant, you know." />
  -->

 

"My lead developer cut some lines of my code, made this ascii art, then pasted said lines underneath it," wrote CM.

############
#|---------\
#|         |
#|         O
#|        -|-
#|         | 
#|        / \
#L_____________________
# GRAVEYARD OF BAD IDEAS

 

Andy P spotted this in their code base.

const float pi = (22.0f/7);

 

"I found this as an example of how to round a number in C#," writes Kendall.

/// <summary>
/// Rounds the specified num.
/// </summary>
/// <param name="num">The num.</param>
/// <param name="place">The place.</param>
/// <returns></returns>
public double Round(double num, int place)
{
    double n;
    n = num * Math.Pow(10, place);
    n = Math.Sign(n) * Math.Abs(Math.Floor(n   .5));
    return n / Math.Pow(10, place);
}

 

"I work on a large website along with another part timer that sometimes makes minor changes to my code," writes Dave D, "usually there's no problem and we work well together, but today I opened up a piece of code I hadn't been into for over a year, only to find a new function added to object.

function filexists($file) {
 $retval=0;
 if(file_exists($file)) $retval=1;
         
 return $retval;
}

 

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!