Click here to Skip to main content
15,889,216 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: Which code you suggest? Pin
Andrew Leeder25-Jul-13 22:34
Andrew Leeder25-Jul-13 22:34 
GeneralRe: Which code you suggest? Pin
OriginalGriff25-Jul-13 22:50
mveOriginalGriff25-Jul-13 22:50 
GeneralRe: Which code you suggest? Pin
SortaCore25-Jul-13 23:15
SortaCore25-Jul-13 23:15 
GeneralRe: Which code you suggest? PinPopular
OriginalGriff25-Jul-13 23:22
mveOriginalGriff25-Jul-13 23:22 
GeneralRe: Which code you suggest? Pin
SortaCore25-Jul-13 23:39
SortaCore25-Jul-13 23:39 
GeneralRe: Which code you suggest? Pin
Stefan_Lang26-Jul-13 0:19
Stefan_Lang26-Jul-13 0:19 
GeneralRe: Which code you suggest? Pin
OriginalGriff26-Jul-13 0:26
mveOriginalGriff26-Jul-13 0:26 
GeneralRe: Which code you suggest? Pin
Stefan_Lang26-Jul-13 1:27
Stefan_Lang26-Jul-13 1:27 
... until you introduce code that needs clean-up at one point or another.

Many of the functions I look at every day are a decade old or more, and consist of several hundred lines of codes with half a dozen levels of nesting or more. Every single one of them allocates stuff, or does something else requiring cleanup. More often than not, this happens before something else happens that necessitates a premature return. Some of the really old functions use goto exit; to immediately jump to the cleanup code. I use a flag.

Sure, not everyone works on such a codebase. But the truth is, the majority of programmers doesn't work on brand-new projects either. 80% work on internal programs designed to improve certain processes inside of a single company. Lots of code, and sometimes with a lifetime higher than that of some of their current programmers. In that context, IME, premature returns are almost always a bad idea.
GeneralRe: Which code you suggest? Pin
svella26-Jul-13 4:42
svella26-Jul-13 4:42 
QuestionRe: Which code you suggest? Pin
Amir Mohammad Nasrollahi28-Jul-13 1:55
professionalAmir Mohammad Nasrollahi28-Jul-13 1:55 
GeneralRe: Which code you suggest? Pin
Stefan_Lang28-Jul-13 22:21
Stefan_Lang28-Jul-13 22:21 
GeneralRe: Which code you suggest? Pin
svella29-Jul-13 4:02
svella29-Jul-13 4:02 
GeneralRe: Which code you suggest? Pin
Stefan_Lang29-Jul-13 22:48
Stefan_Lang29-Jul-13 22:48 
GeneralRe: Which code you suggest? Pin
svella30-Jul-13 3:57
svella30-Jul-13 3:57 
GeneralRe: Which code you suggest? Pin
PIEBALDconsult30-Jul-13 5:44
mvePIEBALDconsult30-Jul-13 5:44 
GeneralRe: Which code you suggest? Pin
Renzo Ciafardone27-Jul-13 16:49
Renzo Ciafardone27-Jul-13 16:49 
GeneralRe: Which code you suggest? Pin
Fabio Franco26-Jul-13 2:59
professionalFabio Franco26-Jul-13 2:59 
GeneralRe: Which code you suggest? Pin
Klaus-Werner Konrad1-Aug-13 12:32
Klaus-Werner Konrad1-Aug-13 12:32 
GeneralRe: Which code you suggest? Pin
Sentenryu25-Jul-13 8:46
Sentenryu25-Jul-13 8:46 
GeneralRe: Which code you suggest? Pin
ZurdoDev30-Jul-13 5:44
professionalZurdoDev30-Jul-13 5:44 
GeneralRe: Which code you suggest? Pin
PIEBALDconsult30-Jul-13 5:43
mvePIEBALDconsult30-Jul-13 5:43 
GeneralRe: Which code you suggest? Pin
César de Souza26-Jul-13 3:06
professionalCésar de Souza26-Jul-13 3:06 
GeneralRe: Which code you suggest? Pin
Argonia26-Jul-13 3:59
professionalArgonia26-Jul-13 3:59 
GeneralRe: Which code you suggest? Pin
César de Souza26-Jul-13 4:41
professionalCésar de Souza26-Jul-13 4:41 
GeneralRe: Which code you suggest? Pin
Ancandune26-Jul-13 2:19
Ancandune26-Jul-13 2:19 

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.