Click here to Skip to main content
15,887,214 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Check for True to return True... Pin
BillW331-Jul-11 4:29
professionalBillW331-Jul-11 4:29 
GeneralRe: Check for True to return True... Pin
PIEBALDconsult1-Jul-11 18:46
mvePIEBALDconsult1-Jul-11 18:46 
GeneralRe: Check for True to return True... Pin
Sander Rossel1-Jul-11 21:28
professionalSander Rossel1-Jul-11 21:28 
GeneralRe: Check for True to return True... Pin
PIEBALDconsult2-Jul-11 4:24
mvePIEBALDconsult2-Jul-11 4:24 
GeneralRe: Check for True to return True... Pin
Lutosław4-Jul-11 2:53
Lutosław4-Jul-11 2:53 
GeneralRe: Check for True to return True... Pin
musefan7-Jul-11 2:30
musefan7-Jul-11 2:30 
GeneralRe: Check for True to return True... Pin
MehGerbil14-Jul-11 2:40
MehGerbil14-Jul-11 2:40 
GeneralThis code may not quite do what it says it does. PinPopular
RCoate29-Jun-11 14:34
RCoate29-Jun-11 14:34 
In preparation for some redevelopment work, I was having a look through some legacy code provided by a contractor. I have a feeling that it does not do exactly what the comments suggest it does.

/// <summary>
/// Determines whether this person already has an application of that type
/// </summary>
/// <param name="appTypeID">The app type ID.</param>
/// <param name="registrationNumber">The registration number.</param>
/// <param name="app">The Application</param>
/// <returns>
///     true if they have an unfinished application of the given type
/// </returns>

private bool HasApplicationAlready(int appTypeID, int registrationNumber, ref Application app)
{
    bool foundOne = false;

    List<Application> matches = new Application().GetApplicationListForContact(DataLocation.OnlineDataBase, Int32.Parse(Profile.RegistrationNumber));

    // We now have all their applications
    // Find their latest application of the correct AppType
    Application bestMatch = null;
    foreach (Application singleApp in matches)
    {
        // See if it's the correct type
        if (singleApp.Application_type_id.GetValueOrDefault(0) == appTypeID)
        {
            // See if it's the most recent application of that type
            if (bestMatch == null)
            {
                bestMatch = singleApp;
            }
            else
            {
                // There's already a match, but see if this one is more recent
                if (singleApp.ApplicationId > bestMatch.ApplicationId)
                {
                    bestMatch = singleApp;
                }
                else
                {
                    bestMatch = singleApp;
                }
            }
        }
    }
    if (bestMatch != null)
    {
        app = bestMatch;
        foundOne = true;
    }
    else
    {
        foundOne = false;
    }
    return foundOne;
}


Another gem I found was:
/// <summary>
/// Does the Final validation.
/// </summary>
/// <returns></returns>
protected bool FinalValidation()
{
    return true;
}

GeneralRe: This code may not quite do what it says it does. Pin
walterhevedeich29-Jun-11 15:35
professionalwalterhevedeich29-Jun-11 15:35 
GeneralRe: This code may not quite do what it says it does. Pin
BobJanova30-Jun-11 3:39
BobJanova30-Jun-11 3:39 
GeneralRe: This code may not quite do what it says it does. Pin
walterhevedeich30-Jun-11 13:15
professionalwalterhevedeich30-Jun-11 13:15 
GeneralRe: This code may not quite do what it says it does. Pin
RCoate30-Jun-11 15:28
RCoate30-Jun-11 15:28 
JokeRe: This code may not quite do what it says it does. Pin
Peter_in_278030-Jun-11 16:05
professionalPeter_in_278030-Jun-11 16:05 
GeneralRe: This code may not quite do what it says it does. Pin
BrainiacV5-Jul-11 7:43
BrainiacV5-Jul-11 7:43 
GeneralRe: This code may not quite do what it says it does. Pin
User 75994145-Jul-11 5:04
User 75994145-Jul-11 5:04 
GeneralRe: This code may not quite do what it says it does. Pin
BobJanova5-Jul-11 7:19
BobJanova5-Jul-11 7:19 
GeneralRe: This code may not quite do what it says it does. Pin
timpattinson5-Jul-11 12:43
timpattinson5-Jul-11 12:43 
GeneralRe: This code may not quite do what it says it does. PinPopular
0bx29-Jun-11 21:23
0bx29-Jun-11 21:23 
GeneralRe: This code may not quite do what it says it does. Pin
BobJanova30-Jun-11 3:26
BobJanova30-Jun-11 3:26 
GeneralRe: This code may not quite do what it says it does. Pin
Tarun.K.S30-Jun-11 3:20
Tarun.K.S30-Jun-11 3:20 
GeneralRe: This code may not quite do what it says it does. Pin
chmod22225-Jul-11 1:52
chmod22225-Jul-11 1:52 
GeneralRe: This code may not quite do what it says it does. Pin
James H5-Jul-11 2:19
James H5-Jul-11 2:19 
GeneralRe: This code may not quite do what it says it does. Pin
chmod22225-Jul-11 2:24
chmod22225-Jul-11 2:24 
GeneralRe: This code may not quite do what it says it does. Pin
James H5-Jul-11 3:38
James H5-Jul-11 3:38 
GeneralRe: This code may not quite do what it says it does. Pin
chmod22225-Jul-11 4:09
chmod22225-Jul-11 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.