Click here to Skip to main content
15,886,919 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: Return the correct null Pin
Sander Rossel26-Jan-17 1:40
professionalSander Rossel26-Jan-17 1:40 
GeneralRe: Return the correct null Pin
User 1013254626-Jan-17 2:18
User 1013254626-Jan-17 2:18 
GeneralRe: Return the correct null Pin
Richard Deeming26-Jan-17 1:48
mveRichard Deeming26-Jan-17 1:48 
GeneralRe: Return the correct null Pin
Lutosław25-Jan-17 23:24
Lutosław25-Jan-17 23:24 
GeneralRe: Return the correct null Pin
KarstenK26-Jan-17 0:32
mveKarstenK26-Jan-17 0:32 
GeneralRe: Return the correct null Pin
F-ES Sitecore26-Jan-17 0:58
professionalF-ES Sitecore26-Jan-17 0:58 
GeneralRe: Return the correct null Pin
Richard Deeming26-Jan-17 1:59
mveRichard Deeming26-Jan-17 1:59 
GeneralTales from J.S. Crypt, Day 3 Pin
Marc Clifton13-Jan-17 3:31
mvaMarc Clifton13-Jan-17 3:31 
A-H are my replacements of more descriptive types to anonymize this drech slightly. I left the misspelling in.
// Function to genearte the Transaction Type Code
public string getTransactionType(string TransactionType)
{
    if (TransactionType == ("A"))
    {
        TransactionType = "1";
    }
    else if (TransactionType == ("B") || TransactionType == ("C"))
    {
        TransactionType = "3";
    }
    else if (TransactionType == ("D") || TransactionType == ("E") || TransactionType == ("F"))
    {
        TransactionType = "4";
    }
    else if (TransactionType == ("G"))
    {
        TransactionType = "5";
    }
    else if (TransactionType == ("H"))
    {
        TransactionType = "6";
    }
    return TransactionType;
}

Now granted, the point is to return a code given a type. But the method is misnamed, the way it's done is horrid, and what's worse, the now encoded type is used everywhere else in the code for conditional logic so you have no idea what the logic is doing without this piece of the type-code map.

And putting strings in parenthesis definitely improves the confidence of the equality test!

Marc
V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation

Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

Artificial intelligence is the only remedy for natural stupidity. - CDP1802

GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Wastedtalent13-Jan-17 3:38
professionalWastedtalent13-Jan-17 3:38 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Marc Clifton13-Jan-17 4:01
mvaMarc Clifton13-Jan-17 4:01 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Wastedtalent13-Jan-17 4:23
professionalWastedtalent13-Jan-17 4:23 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
OriginalGriff13-Jan-17 4:40
mveOriginalGriff13-Jan-17 4:40 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Marc Clifton14-Jan-17 10:40
mvaMarc Clifton14-Jan-17 10:40 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Nagy Vilmos13-Jan-17 4:39
professionalNagy Vilmos13-Jan-17 4:39 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Jon McKee14-Jan-17 11:02
professionalJon McKee14-Jan-17 11:02 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Bernhard Hiller15-Jan-17 20:57
Bernhard Hiller15-Jan-17 20:57 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Harrison Pratt16-Jan-17 2:40
professionalHarrison Pratt16-Jan-17 2:40 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Greg Lovekamp17-Jan-17 4:19
professionalGreg Lovekamp17-Jan-17 4:19 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Harrison Pratt17-Jan-17 12:10
professionalHarrison Pratt17-Jan-17 12:10 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Sander Rossel22-Jan-17 0:25
professionalSander Rossel22-Jan-17 0:25 
GeneralRe: Tales from J.S. Crypt, Day 3 Pin
Jörgen Andersson22-Jan-17 8:10
professionalJörgen Andersson22-Jan-17 8:10 
GeneralTales from the Crypt Pin
Marc Clifton12-Jan-17 3:38
mvaMarc Clifton12-Jan-17 3:38 
GeneralRe: Tales from the Crypt Pin
MarkTJohnson12-Jan-17 4:08
professionalMarkTJohnson12-Jan-17 4:08 
GeneralRe: Tales from the Crypt Pin
Richard Deeming12-Jan-17 7:17
mveRichard Deeming12-Jan-17 7:17 
GeneralRe: Tales from the Crypt Pin
Bernhard Hiller12-Jan-17 20:47
Bernhard Hiller12-Jan-17 20:47 

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.