Click here to Skip to main content
15,887,446 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: Found in old code Pin
CDP180226-Jul-16 3:40
CDP180226-Jul-16 3:40 
PraiseRe: Found in old code Pin
Jeremy Falcon9-Sep-16 9:03
professionalJeremy Falcon9-Sep-16 9:03 
GeneralBut it works ... PinPopular
Richard MacCutchan31-May-16 3:08
mveRichard MacCutchan31-May-16 3:08 
JokeRe: But it works ... Pin
Power Puff Boy31-May-16 21:39
Power Puff Boy31-May-16 21:39 
GeneralRe: But it works ... Pin
Kornfeld Eliyahu Peter31-May-16 22:27
professionalKornfeld Eliyahu Peter31-May-16 22:27 
GeneralRe: But it works ... Pin
Richard MacCutchan31-May-16 22:36
mveRichard MacCutchan31-May-16 22:36 
GeneralRe: But it works ... Pin
Bernhard Hiller31-May-16 23:49
Bernhard Hiller31-May-16 23:49 
GeneralRe: But it works ... Pin
David A. Gray1-Jul-16 21:18
David A. Gray1-Jul-16 21:18 
Reading this thread reminds me of a short story that I read long ago. I can no longer remember whether I was in high school or college; the only reason that has any relevance is that I have forgotten the story, but not its title, "Insert Flap A and Throw It Away."

I have learned, and am periodically reminded of its importance, that if a function returns a value, even if it is poop, you would do well to check it. After all, if the author thought it was important enough to return, who am I to brush him off by ignoring it?

Plenty of authors have written plenty of functions that return void. In all versions of BASIC, these are called Subs, short for Subroutines. Their author is effectively saying, "I have nothing to report; just trust me."

A couple of weeks ago, I ran across a method that returns void that I wish didn't. The method in question, Console.WriteLine() would be much more useful if it returned a character count, along the lines of what you can get from printf(), but probably aren't. Almost every example I see that uses printf() doesn't bother with the return code. This is so prevalent that I hadn't given the matter any consideration until I started working with its buffered cousin, sprintf(). Along the way, I discovered that both have a return value of type int, which returns the number of characters written. While the newer "secure" print functions in the latest Visual C runtime library return minus one to indicate failure, even the old ones can be persuaded to print nothing and return zero.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting

GeneralSA1122 : CSharp.Readability Pin
Eddy Vluggen30-May-16 4:17
professionalEddy Vluggen30-May-16 4:17 
GeneralRe: SA1122 : CSharp.Readability Pin
Chris Maunder30-May-16 4:46
cofounderChris Maunder30-May-16 4:46 
GeneralRe: SA1122 : CSharp.Readability Pin
Eddy Vluggen30-May-16 4:57
professionalEddy Vluggen30-May-16 4:57 
GeneralRe: SA1122 : CSharp.Readability Pin
OriginalGriff30-May-16 5:12
mveOriginalGriff30-May-16 5:12 
GeneralRe: SA1122 : CSharp.Readability Pin
TheGreatAndPowerfulOz30-May-16 6:07
TheGreatAndPowerfulOz30-May-16 6:07 
GeneralRe: SA1122 : CSharp.Readability Pin
Eddy Vluggen30-May-16 6:21
professionalEddy Vluggen30-May-16 6:21 
QuestionRe: SA1122 : CSharp.Readability Pin
TigerInside14-Jun-16 2:27
professionalTigerInside14-Jun-16 2:27 
AnswerRe: SA1122 : CSharp.Readability Pin
Eddy Vluggen14-Jun-16 3:21
professionalEddy Vluggen14-Jun-16 3:21 
GeneralRe: SA1122 : CSharp.Readability Pin
Kornfeld Eliyahu Peter30-May-16 6:34
professionalKornfeld Eliyahu Peter30-May-16 6:34 
GeneralRe: SA1122 : CSharp.Readability Pin
Eddy Vluggen30-May-16 6:52
professionalEddy Vluggen30-May-16 6:52 
GeneralRe: SA1122 : CSharp.Readability Pin
Kornfeld Eliyahu Peter30-May-16 7:33
professionalKornfeld Eliyahu Peter30-May-16 7:33 
GeneralRe: SA1122 : CSharp.Readability Pin
PIEBALDconsult30-May-16 6:37
mvePIEBALDconsult30-May-16 6:37 
GeneralRe: SA1122 : CSharp.Readability Pin
Eddy Vluggen30-May-16 6:44
professionalEddy Vluggen30-May-16 6:44 
GeneralRe: SA1122 : CSharp.Readability Pin
Deflinek30-May-16 7:30
Deflinek30-May-16 7:30 
GeneralRe: SA1122 : CSharp.Readability Pin
Eddy Vluggen30-May-16 7:53
professionalEddy Vluggen30-May-16 7:53 
GeneralRe: SA1122 : CSharp.Readability Pin
Deflinek30-May-16 8:10
Deflinek30-May-16 8:10 
GeneralRe: SA1122 : CSharp.Readability Pin
Eddy Vluggen30-May-16 8:23
professionalEddy Vluggen30-May-16 8:23 

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.