Click here to Skip to main content
15,565,403 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: Efficiency redux Pin
Lutosław28-Jul-12 0:07
Lutosław28-Jul-12 0:07 
GeneralRe: Efficiency redux Pin
Fran Porretto19-Jul-12 1:46
Fran Porretto19-Jul-12 1:46 
GeneralRe: Efficiency redux Pin
BillW3319-Jul-12 2:48
professionalBillW3319-Jul-12 2:48 
GeneralRe: Efficiency redux Pin
BobJanova19-Jul-12 3:42
BobJanova19-Jul-12 3:42 
GeneralRe: Efficiency redux Pin
onemorechance19-Jul-12 3:11
onemorechance19-Jul-12 3:11 
GeneralRe: Efficiency redux Pin
Lutosław28-Jul-12 0:16
Lutosław28-Jul-12 0:16 
GeneralRe: Efficiency redux Pin
rtklueh19-Jul-12 6:19
rtklueh19-Jul-12 6:19 
General1,2,3,4...lots of...what exactly? PinPopular
Andrei Straut18-Jul-12 5:49
Andrei Straut18-Jul-12 5:49 
While debugging a legacy stored proc from one of our systems, I've come across this:

CREATE PROCEDURE p_create_po_serial (
          IN param_reception_ids VARCHAR(255),
          IN param_serial_nos VARCHAR(1023),
          OUT serial_no_ids VARCHAR(1023))
BEGIN  
  /*Current reception id to parse*/
  DECLARE id_to_parse VARCHAR(255);
  /*Left reception ids to parse*/
  DECLARE temp_reception_ids VARCHAR(255);
  /*Counter to count something, I'll figure out later what I need it for*/
  DECLARE c*** INT;
  SET temp_reception_ids = param_reception_ids;
  SET serial_no_ids = '';
  SET c*** = 0;
  
  WHILE (length(temp_reception_ids) > 0) DO
    SET id_to_parse = SUBSTRING_INDEX(temp_reception_ids, ';', 1);
    SET serial_no_ids = concat(serial_no_ids, '-', id_to_parse);
    
    <Some 200 more lines, in which 'c***' makes absolutely no appearance whatsoever>

    SET temp_reception_ids = SUBSTRING(temp_reception_ids, length(id_to_parse) + 2, length(temp_reception_ids));
    SELECT id_to_parse, temp_reception_ids;
    SET c*** = c*** + 1;
  END WHILE;
  
END;


No variable or method names have been replaced. That would've taken away all the beauty of it.

Now, what I've actually been amused exactly, is that besides the funny (intended or not) misspelling of 'count' - and yes, I know CP will replace the variable name with '*', is that absolutely no-one knows what the counter was supposed to be used for. Counting the while steps maybe?

However, on the grander scheme of things, this proc is actually quite ok, and it even has comments OMG | :OMG: (and yes, they were useful)!! And what it was supposed to do was this:
- Take a string parameter that contained some IDs separated by ';'
- Take each id from that string and do some selects using that id as parameter
- Extract data from those selects and do some inserts / updates with it, depending on some other conditions

But again, that count, and its associated comment, just made my day!
Full-fledged Java/.NET lover, full-fledged PHP hater.
Full-fledged Google/Microsoft lover, full-fledged Apple hater.
Full-fledged Skype lover, full-fledged YM hater.

GeneralRe: 1,2,3,4...lots of...what exactly? Pin
BillW3318-Jul-12 7:37
professionalBillW3318-Jul-12 7:37 
GeneralRe: 1,2,3,4...lots of...what exactly? Pin
Andrei Straut18-Jul-12 9:09
Andrei Straut18-Jul-12 9:09 
GeneralRe: 1,2,3,4...lots of...what exactly? Pin
Shameel25-Jul-12 3:11
professionalShameel25-Jul-12 3:11 
GeneralRe: 1,2,3,4...lots of...what exactly? Pin
S Houghtelin19-Jul-12 3:21
professionalS Houghtelin19-Jul-12 3:21 
GeneralMake sure this value is returned... Pin
cmger18-Jul-12 4:21
cmger18-Jul-12 4:21 
GeneralRe: Make sure this value is returned... Pin
BillW3318-Jul-12 5:07
professionalBillW3318-Jul-12 5:07 
GeneralRe: Make sure this value is returned... Pin
cmger18-Jul-12 5:34
cmger18-Jul-12 5:34 
GeneralRe: Make sure this value is returned... Pin
Andrei Straut18-Jul-12 5:56
Andrei Straut18-Jul-12 5:56 
GeneralRe: Make sure this value is returned... Pin
BillW3318-Jul-12 7:32
professionalBillW3318-Jul-12 7:32 
GeneralRe: Make sure this value is returned... Pin
cmger18-Jul-12 21:34
cmger18-Jul-12 21:34 
GeneralRe: Make sure this value is returned... Pin
BillW3319-Jul-12 8:22
professionalBillW3319-Jul-12 8:22 
GeneralRe: Make sure this value is returned... Pin
greldak18-Jul-12 22:53
greldak18-Jul-12 22:53 
GeneralRe: Make sure this value is returned... Pin
Renzo Ciafardone19-Jul-12 8:24
Renzo Ciafardone19-Jul-12 8:24 
GeneralA new definition of efficiency Pin
PaulLinton16-Jul-12 20:57
PaulLinton16-Jul-12 20:57 
GeneralRe: A new definition of efficiency Pin
enhzflep16-Jul-12 21:31
enhzflep16-Jul-12 21:31 
GeneralRe: A new definition of efficiency Pin
RobCroll16-Jul-12 22:13
RobCroll16-Jul-12 22:13 
GeneralRe: A new definition of efficiency Pin
OriginalGriff16-Jul-12 23:39
mvaOriginalGriff16-Jul-12 23:39 

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.