Click here to Skip to main content
15,887,322 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.

 
GeneralThere is nothing new under the sun... Pin
Duncan Edwards Jones9-Apr-14 7:22
professionalDuncan Edwards Jones9-Apr-14 7:22 
GeneralRe: There is nothing new under the sun... Pin
I.explore.code9-Apr-14 7:41
I.explore.code9-Apr-14 7:41 
GeneralRe: There is nothing new under the sun... Pin
Chris Maunder9-Apr-14 7:55
cofounderChris Maunder9-Apr-14 7:55 
GeneralRe: There is nothing new under the sun... Pin
Kornfeld Eliyahu Peter9-Apr-14 10:05
professionalKornfeld Eliyahu Peter9-Apr-14 10:05 
GeneralRe: There is nothing new under the sun... Pin
Rob Grainger10-Apr-14 23:30
Rob Grainger10-Apr-14 23:30 
GeneralRe: There is nothing new under the sun... Pin
Duncan Edwards Jones10-Apr-14 23:49
professionalDuncan Edwards Jones10-Apr-14 23:49 
GeneralRe: There is nothing new under the sun... Pin
Sander Rossel24-Apr-14 7:42
professionalSander Rossel24-Apr-14 7:42 
GeneralHow not to do transaction processing Pin
Rob Grainger9-Apr-14 6:12
Rob Grainger9-Apr-14 6:12 
Yet another disastrous example from the VB6 project I'm porting. In many ways this one is truly eye-popping...
(Note, the code is paraphrased to avoid spilling "secrets" (like anyone would steal this carp)).

VB
Dim con As ADODB.Connection

Sub DoSomething()
    ...
    con.BeginTrans
    ...
    On Error GoTo MyRollback

    ... Various statements that insert records ...

    con.CommitTrans

    ...
    Exit Sub

MyRollback:

    MsgBox Err.Description
    con.RollbackTrans
    Resume Next                ' WTF!!!!
End Sub


So, if an error is detected, the current transaction is aborted but the code then attempts to write the remaining inserts anyway - only not outside of a transaction.
Of course it all goes pear-shaped when the Commit is attempted, but by that stage a whole bunch of detritus will have accumulated in the database.

And as there are pretty well no relationships in this DB, there's nothing preventing those records being utterly invalid (and they will be).

I predict a monumental data cleanup task approaching!
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.

GeneralRe: How not to do transaction processing Pin
Duncan Edwards Jones9-Apr-14 7:13
professionalDuncan Edwards Jones9-Apr-14 7:13 
GeneralRe: How not to do transaction processing Pin
Rob Grainger10-Apr-14 4:12
Rob Grainger10-Apr-14 4:12 
GeneralRe: How not to do transaction processing Pin
W Balboos, GHB11-Apr-14 1:14
W Balboos, GHB11-Apr-14 1:14 
GeneralRe: How not to do transaction processing Pin
clawton9-Apr-14 12:30
clawton9-Apr-14 12:30 
GeneralRe: How not to do transaction processing Pin
BobJanova9-Apr-14 23:39
BobJanova9-Apr-14 23:39 
GeneralRe: How not to do transaction processing Pin
Rob Grainger10-Apr-14 4:14
Rob Grainger10-Apr-14 4:14 
RantI just can't take it no more! Pin
Super Lloyd9-Apr-14 0:10
Super Lloyd9-Apr-14 0:10 
GeneralRe: I just can't take it no more! Pin
Duncan Edwards Jones9-Apr-14 0:20
professionalDuncan Edwards Jones9-Apr-14 0:20 
GeneralRe: I just can't take it no more! Pin
Sentenryu9-Apr-14 0:23
Sentenryu9-Apr-14 0:23 
GeneralRe: I just can't take it no more! Pin
Duncan Edwards Jones9-Apr-14 0:42
professionalDuncan Edwards Jones9-Apr-14 0:42 
GeneralRe: I just can't take it no more! Pin
Sentenryu9-Apr-14 1:13
Sentenryu9-Apr-14 1:13 
GeneralRe: I just can't take it no more! Pin
Duncan Edwards Jones9-Apr-14 1:21
professionalDuncan Edwards Jones9-Apr-14 1:21 
GeneralRe: I just can't take it no more! Pin
Super Lloyd9-Apr-14 15:11
Super Lloyd9-Apr-14 15:11 
GeneralRe: I just can't take it no more! Pin
Sentenryu10-Apr-14 0:43
Sentenryu10-Apr-14 0:43 
GeneralRe: I just can't take it no more! Pin
ZurdoDev9-Apr-14 1:24
professionalZurdoDev9-Apr-14 1:24 
GeneralRe: I just can't take it no more! Pin
PIEBALDconsult9-Apr-14 3:15
mvePIEBALDconsult9-Apr-14 3:15 
GeneralRe: I just can't take it no more! Pin
Super Lloyd9-Apr-14 15:12
Super Lloyd9-Apr-14 15:12 

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.