"We had a programmer in our company whose specialty was to write functions that embodied his own personal traits," Winston Muller, writes "do absolutely nothing and mislead everyone to think that something was done."

/// <summary>
/// Log the user off the system. The method returns true or false for success or failure
/// </summary>
public bool Logoff(string strUser)
{
  return true;
}

 

"I spotted this comment while debugging our production codebase," notes Corey F

// 04/08/01 - removing inventory verification
// ** this could be part of the reason that we 
// ** never make money on chemicals

 

"This 'abstract' class is subclassed by all of the homebrew enums we have," writes Miguel de Anda

public class AbstractConstants implements Serializable {

 

"I came across this great example of how not to name variables," notes Peter Horsley, "it also has an intriguing 5-level deep object hierarchy of what look like enums."

 

Stefan L's colleague is not a fan of magic numbers.

#define NR_OF_PARAMS_0  0
#define NR_OF_PARAMS_1  1
#define NR_OF_PARAMS_2  2
#define NR_OF_PARAMS_3  3
#define NR_OF_PARAMS_4  4
#define NR_OF_PARAMS_5  5
#define NR_OF_PARAMS_6  6
#define NR_OF_PARAMS_7  7
#define NR_OF_PARAMS_8  8
#define NR_OF_PARAMS_9  9
#define NR_OF_PARAMS_10 10
#define NR_OF_PARAMS_11 11
#define NR_OF_PARAMS_12 12
#define NR_OF_PARAMS_13 13
#define NR_OF_PARAMS_14 14
#define NR_OF_PARAMS_15 15

 

"In case it's not obvious from the class names," writes Veggen Skrikk, "the only difference between the beans is that one (unsuccessfully) attempts to use DB transactions and another does not. Naturally, they both operated on the same underlying database table. This was the previous guy's way to introduce experimental features into the application. Experimental features like transactions. That don't work."

public class OrderUpdateBean implements Serializable { ... }

...

public class UpdateOrderBean implements Serializable { ... }

 

"I was doing some work on production code and found this rather odd definition of a second," writes Erik, "It seems that the tasks meant to execute once every second will actually execute five times per second."

#define TASK_RATE               (5) //Task rate in milliseconds
#define TASK_RATE_ONE_SECOND    (TASK_RATE * 40)
#define TASK_RATE_FOUR_SECONDS  (TASK_RATE_ONE_SECOND * 4)

 

"We really believe in safe coding," Ryan writes, "though, I'd sure like to see the circumstances when this exception could be thrown..."

public override void ManageRelations()
{
    try
    {
        return;
    }
    catch (Exception ex)
    {
        throw new Exception("Error in ManageRelations method of Biz Rules media of HE", ex);
    }
}

 

"An enterprise messaging app went to a client with some 'testing' code in it," Matt writes, "thankfully, the client had no idea they could change the language, and this went unnoticed for years."

private var languageLabels:ArrayCollection = new ArrayCollection(
					"English",
					"German",
					"French",
					"Gay"
					);

"I saw this in a project-wide static utility class," Keith Bluestone wrote, "you could pretty much say this developer either lacks a concept of the 'if' statement or the inherent qualities of null-ness:"

    public static string GetStringValue(object obj)
    {
        if (obj == null)
        {
            return "";
        }
        if ((obj == null))
        {
            return "";
        }
        if (!(obj == null))
        {
            return obj.ToString();
        }
        else
        {
            return "";
        }
    }