Click here to Skip to main content
15,905,229 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: Checking for empty guid Pin
JMK-NI26-Jun-14 11:19
professionalJMK-NI26-Jun-14 11:19 
GeneralRe: Checking for empty guid Pin
Bernhard Hiller27-Jun-14 0:11
Bernhard Hiller27-Jun-14 0:11 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult27-Jun-14 4:37
mvePIEBALDconsult27-Jun-14 4:37 
GeneralRe: Checking for empty guid Pin
Bernhard Hiller27-Jun-14 0:06
Bernhard Hiller27-Jun-14 0:06 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult27-Jun-14 4:38
mvePIEBALDconsult27-Jun-14 4:38 
GeneralRe: Checking for empty guid Pin
Nagy Vilmos27-Jun-14 1:59
professionalNagy Vilmos27-Jun-14 1:59 
GeneralRe: Checking for empty guid Pin
Richard Deeming27-Jun-14 2:36
mveRichard Deeming27-Jun-14 2:36 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult27-Jun-14 3:11
mvePIEBALDconsult27-Jun-14 3:11 
GeneralRe: Checking for empty guid Pin
Richard Deeming27-Jun-14 3:21
mveRichard Deeming27-Jun-14 3:21 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult27-Jun-14 4:26
mvePIEBALDconsult27-Jun-14 4:26 
GeneralInteresting... Pin
Dave Kreskowiak23-Jun-14 2:53
mveDave Kreskowiak23-Jun-14 2:53 
GeneralRe: Interesting... Pin
Simon Lee Shugar23-Jun-14 3:10
Simon Lee Shugar23-Jun-14 3:10 
GeneralRe: Interesting... Pin
0bx23-Jun-14 6:42
0bx23-Jun-14 6:42 
GeneralRe: Interesting... Pin
Bernhard Hiller23-Jun-14 22:37
Bernhard Hiller23-Jun-14 22:37 
GeneralRe: Interesting... Pin
Shameel30-Jun-14 23:48
professionalShameel30-Jun-14 23:48 
GeneralRe: Interesting... Pin
Richard Deeming23-Jun-14 11:26
mveRichard Deeming23-Jun-14 11:26 
GeneralRe: Interesting... Pin
musefan24-Jun-14 4:32
musefan24-Jun-14 4:32 
GeneralRe: Interesting... Pin
Dave Kreskowiak24-Jun-14 4:50
mveDave Kreskowiak24-Jun-14 4:50 
GeneralRe: Interesting... Pin
musefan25-Jun-14 4:39
musefan25-Jun-14 4:39 
GeneralRe: Interesting... Pin
BillW3326-Jun-14 10:41
professionalBillW3326-Jun-14 10:41 
GeneralRe: Interesting... Pin
Brisingr Aerowing30-Jun-14 17:41
professionalBrisingr Aerowing30-Jun-14 17:41 
GeneralRe: Interesting... Pin
Marc Koutzarov29-Aug-14 22:09
professionalMarc Koutzarov29-Aug-14 22:09 
GeneralNot the best example in the book Pin
BotCar22-Jun-14 21:18
BotCar22-Jun-14 21:18 
I was in a training course last week where the below code was used as part of an example. It was described as a method that would generate a unique ID and add the specified prefix to it.

Java
public static String generateId(String prefix)
{
    int randomNumber = new Random().nextInt();

    String id = Integer.toString(randomNumber);

    if(id.startsWith("-"))
    {
        id = id.replace('-', '3');
        id = prefix + id;
    }

    return id;
}


Apart from the flaws that I'm sure you'll spot, I should point out that this was in the context of server-side code that forms part of a workflow. So depending on how often the workflow executes, it could be likely that multiple instances of the workflow would execute at the same time and generate the same "unique" ID.
What is this talk of release? I do not release software. My software escapes leaving a bloody trail of designers and quality assurance people in its wake.

GeneralRe: Not the best example in the book Pin
Peter_in_278023-Jun-14 16:49
professionalPeter_in_278023-Jun-14 16:49 
GeneralRe: Not the best example in the book Pin
BotCar23-Jun-14 19:26
BotCar23-Jun-14 19:26 

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.