"I just inherited a PHP application and discovered this," writes David Green. "I don't know what's worse: the fact that it says add but is performing subtraction, or that I can't find the accompanying addnoise() function."
public function addfunk($one, $two) { $val = $one - $two; return $val; }
"I know what a Boolean is, and a know what Mutable means," Casey Borders writes, "yet I have no idea what a MutableBoolean is."
class MutableBoolean { public boolean value = true; public MutableBoolean(boolean v) { value = v; } }
"I found this comment above a function written by an former co-worker," Craig wrote, "I guess he was the master of the quadruple negative. I still can't tell if this shows or hides the dialog."
/** *Makes the following dialog not non-uninvisible */
"I was browsing through the morass that is our excessively layered code base when I stumbled upon this gem of genius programming," Sebastian writes, "I started sobbing a little and people looked at me like I was some weirdo."
private boolean isLoggingEnabled() { return MAX_NUMBER_ATTACHMENTS != -1; }
Stu writes, "I was reviewing some code in a WCF service written by a former colleague and came across this little gem of utter redundancy."
public bool IsOk { get { return value >= 0; } } public bool IsNotOk { get { return !IsOk; } }
Jasmine submitted this snippet from the Submit To WTF Visual Studio Add-In.
Public Function IsObjNothing(ByRef poObject As Object) As Boolean '***** 04/21/2004 - corrected function IsObjNothing expression type 'IsObjNothing = (TypeName(poObject) = Nothing) IsObjNothing = (TypeName(poObject).ToUpper = "NOTHING") End Function
"While taking a stroll through the code on a new project, I came across a fantabulous override of ToString," Jay writes, "I guess you never know when this
will be null."
Rakkhi stumbled across the best HelloWorldApp comment header yet:
/* * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of Oracle or the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * The HelloWorldApp class implements an application that * simply prints "Hello World!" to standard output. */ class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); // Display the string. } }
"While cleaning up some pretty awful header files in a legacy system I found this macro," writes Cainan, "it's bound to simplify something for someone."
#define HEX(A) (0xA) // "SIMPLIFY DECLARATION"
"As if this function isn't useless enough as it is, note that the unit is off," notes Mike Wacker, "timeInSeconds should really be timeInMilliseconds."
public static void Wait(int timeInSeconds) { for (int i = 0; i < timeInSeconds / 100; i++) { Thread.Sleep(100); } }