"The company I work for sells text-message related web services," writes Martin S. "Basically, you buy a subscription and then get access to our SMS gateway that has all sorts of fancy features."

"Being that we sell technology to other companies, I sort-of expected the codebase to be... well, not like this. Take, for example, this function (one of many of its kind) that verifies that a string only contains numbers."

private string checkChars(string destination)
{
    ArrayList validCharacters = new ArrayList();

    validCharacters.Add("0");
    validCharacters.Add("1");
    validCharacters.Add("2");
    validCharacters.Add("3");
    validCharacters.Add("4");
    validCharacters.Add("5");
    validCharacters.Add("6");
    validCharacters.Add("7");
    validCharacters.Add("8");
    validCharacters.Add("9");

    bool validChars = true;

    for (int i=0; i < destination.Length; i++)
    {
        string matchedChar = "N";

        foreach (string character in validCharacters)
        {
            if (destination.Substring(i, 1) == character)
            {
                matchedChar = "Y";

                break;
            }
        }

        if (matchedChar == "N")
        {
            LogDebug("checkChars -> Invalid character found: " + destination.Substring(i, 1));
            
            validChars = false;
        }
    }

    string charStatus;

    if (validChars)
    {
        LogDebug("checkChars -> All characters ok");
        
        charStatus = "0";
    }
    else
    {
        LogDebug("checkChars -> Invalid characters found");
        
        charStatus = "1";
    }

    return charStatus;
}

Martin continues, "I'm not sure which is worse, the string return value of '0' or '1' or the ArrayList of numbers. I've found plenty of other similar functions but this is a nice standalone example.